操控键盘
import pyautogui
#typewrite()无法输入中文内容,中英文混合的只能输入英文
#interval设置文本输入速度,默认值为0
pyautogui.typewrite('你好,world!',interval=0.5)
操控鼠标
import pyautogui as pg
try:
while True:
x, y = pg.position()
print(str(x) + " " + str(y)) #输出鼠标位置
if 1746 < x < 1800 and 2 < y < 33:
pg.click()#左键单击
if 1200 < x < 1270 and 600 < y < 620:
pg.click(button='right')#右键单击
if 1646 < x < 1700 and 2 < y < 33:
pg.doubleClick()#左键双击
except KeyboardInterrupt:
print("\n")