rpa_sendHotKey

模拟键盘按键,支持单个按键模拟,也支持Ctrl、Alt、Shift、Win + 其他按键的组合键模拟。该函数后续版本将废弃,使用API rpa_sendKeys()替换。

注意:该函数运行时,键盘操作可能影响结果,若机器人中使用了该API,机器人执行时避免人为操作键盘

1. 函数

rpa_sendHotKey(key, ctrl=False, alt=False, shift=False, win=False)

  • key:数字及字符用对应按键字符(如'a', '1'等),特殊字符定义如下(Key.enter表示回车):

    class Key(enum.Enum):
        # Default keys
        alt = KeyCode._from_symbol('Alt_L')
        alt_l = KeyCode._from_symbol('Alt_L')
        alt_r = KeyCode._from_symbol('Alt_R')
        alt_gr = KeyCode._from_symbol('Mode_switch')
        backspace = KeyCode._from_symbol('BackSpace')
        caps_lock = KeyCode._from_symbol('Caps_Lock')
        cmd = KeyCode._from_symbol('Super_L')
        cmd_l = KeyCode._from_symbol('Super_L')
        cmd_r = KeyCode._from_symbol('Super_R')
        ctrl = KeyCode._from_symbol('Control_L')
        ctrl_l = KeyCode._from_symbol('Control_L')
        ctrl_r = KeyCode._from_symbol('Control_R')
        delete = KeyCode._from_symbol('Delete')
        down = KeyCode._from_symbol('Down')
        end = KeyCode._from_symbol('End')
        enter = KeyCode._from_symbol('Return')
        esc = KeyCode._from_symbol('Escape')
        f1 = KeyCode._from_symbol('F1')
        f2 = KeyCode._from_symbol('F2')
        f3 = KeyCode._from_symbol('F3')
        f4 = KeyCode._from_symbol('F4')
        f5 = KeyCode._from_symbol('F5')
        f6 = KeyCode._from_symbol('F6')
        f7 = KeyCode._from_symbol('F7')
        f8 = KeyCode._from_symbol('F8')
        f9 = KeyCode._from_symbol('F9')
        f10 = KeyCode._from_symbol('F10')
        f11 = KeyCode._from_symbol('F11')
        f12 = KeyCode._from_symbol('F12')
        f13 = KeyCode._from_symbol('F13')
        f14 = KeyCode._from_symbol('F14')
        f15 = KeyCode._from_symbol('F15')
        f16 = KeyCode._from_symbol('F16')
        f17 = KeyCode._from_symbol('F17')
        f18 = KeyCode._from_symbol('F18')
        f19 = KeyCode._from_symbol('F19')
        f20 = KeyCode._from_symbol('F20')
        home = KeyCode._from_symbol('Home')
        left = KeyCode._from_symbol('Left')
        page_down = KeyCode._from_symbol('Page_Down')
        page_up = KeyCode._from_symbol('Page_Up')
        right = KeyCode._from_symbol('Right')
        shift = KeyCode._from_symbol('Shift_L')
        shift_l = KeyCode._from_symbol('Shift_L')
        shift_r = KeyCode._from_symbol('Shift_R')
        space = KeyCode._from_symbol('space', char=' ')
        tab = KeyCode._from_symbol('Tab')
        up = KeyCode._from_symbol('Up')
    
        insert = KeyCode._from_symbol('Insert')
        menu = KeyCode._from_symbol('Menu')
        num_lock = KeyCode._from_symbol('Num_Lock')
        pause = KeyCode._from_symbol('Pause')
        print_screen = KeyCode._from_symbol('Print')
        scroll_lock = KeyCode._from_symbol('Scroll_Lock')
    
  • ctrl:bool类型,True表示同时按下Ctrl键,False表示不按下Ctrl键;

  • alt:bool类型,True表示同时按下Alt键,False表示不按下Alt键;

  • shift:bool类型,True表示同时按下Shift键,False表示不按下Shift键;

  • win:bool类型,True表示同时按下Win键,False表示不按下Win键。

2. 返回值

该函数没有返回值。

3. 示例

  • 发送按键打开资源管理器
# 按下e键
key='e'
# 不按下Ctrl键
ctrl=False
# 不按下Alt键
alt=False
# 不按下Shift键
shift=False
# 按下Win键
win=True

# 模拟按下Win + e组合键
rpa_sendHotKey(key, ctrl, alt, shift, win)
powered by Gitbook修订时间: 2021-04-15 15:56:54

找到相关内容

    未找到""相关内容

    找到相关内容

      未找到""相关内容