pyautogui.typewrite('Hello world!') # 输入Hello world!字符串
pyautogui.typewrite('Hello world!', interval=0.25)
# 每次输入间隔0.25秒,输入Hello world!
pyautogui.press('enter') # 按下并松开(轻敲)回车键
pyautogui.press(['left', 'left', 'left', 'left']) # 按下并松开(轻敲)四下左方向键
pyautogui.keyDown('shift') # 按下`shift`键
pyautogui.keyUp('shift') # 松开`shift`键
pyautogui.keyDown('shift')
pyautogui.press('4')
pyautogui.keyUp('shift') # 输出 $ 符号的按键
pyautogui.hotkey('ctrl', 'v')
# 组合按键(Ctrl+V),粘贴功能,按下并松开'ctrl'和'v'按键
键盘键字符串 含义
'a','b','c','A','C','1','2','3', 单个字符的键
'!','@','#'等
'enter' 回车
‘esc' ESC键
'shiftleft','shiftright' 左右Shift键
'altleft','altright' 左右Alt键
'ctrlleft','ctrlright' 左右Ctrl键
‘tab'(or '\t') Tab键
'backspace','delete' Backspace键和Delete键
'pageup','pagedown' Page Up 和Page Down键
'home','end' Home键和End键
'up','down','left','right' 上下左右箭头键
'f1','f2','f3'等 F1至F12键
'volumemute','volumeup',volumedown' 静音,放大音量和减小音量键
'pause' 暂停键
'capslock','numlock','scrolllock' Caps Lock,Num Lock和 Scroll Lock键
'insert' Insert键
'printscreen' Prtsc或Print Screen键
'winleft','winright' 左右Win键(在windows上)
'command' Command键(在OS X上)
'option' Option键(在OS X上)