SendKeys总结

it2024-07-15  82

1.SendKeys中特殊字符的键代码BACKSPACE {BACKSPACE}、{BS} 或 {BKSP} BREAK {BREAK} CAPS LOCK {CAPSLOCK} DEL 或 DELETE {DELETE} 或 {DEL} DOWN ARROW(下箭头) {DOWN} END {END} ENTER {ENTER} 或 ~ ESC {ESC} HELP {HELP} HOME {HOME} INS 或 INSERT {INSERT} 或 {INS} LEFT ARROW(左箭头) {LEFT} NUM LOCK {NUMLOCK} PAGE DOWN {PGDN} PAGE UP {PGUP} PRINT SCREEN {PRTSC}(保留,以备将来使用) RIGHT ARROW(右箭头) {RIGHT} SCROLL LOCK {SCROLLLOCK} TAB {TAB} UP ARROW(上箭头) {UP} F1 {F1} F2 {F2} F3 {F3} F4 {F4} F5 {F5} F6 {F6} F7 {F7} F8 {F8} F9 {F9} F10 {F10} F11 {F11} F12 {F12} F13 {F13} F14 {F14} F15 {F15} F16 {F16} 数字盘加号 {ADD} 数字盘减号 {SUBTRACT} 数字盘乘号 {MULTIPLY} 数字盘除号 {DIVIDE}

2.如何输入空格空格

def SendKeys(keys, pause=0.05, with_spaces=False, with_tabs=False, with_newlines=False, turn_off_numlock=True): /  """    Sends keys to the current window.    `keys` : str        A string of keys.    `pause` : float        The number of seconds to wait between sending each key        or key combination.    `with_spaces` : bool        Whether to treat spaces as ``{SPACE}``. If `False`, spaces are ignored.    `with_tabs` : bool        Whether to treat tabs as ``{TAB}``. If `False`, tabs are ignored.    `with_newlines` : bool        Whether to treat newlines as ``{ENTER}``. If `False`, newlines are ignored.    `turn_off_numlock` : bool        Whether to turn off `NUMLOCK` before sending keys.    example::        SendKeys("+hello{SPACE}+world+1")    would result in ``"Hello World!"``    """

 example:

 SendKeys.SendKeys('Hello Word!',0.05,True,True,True,True)

 

转载于:https://www.cnblogs.com/ybcao/p/5459814.html

最新回复(0)