赞
踩
pip install pyautogui
用途 | 代码 |
---|---|
获取位置 | posititon |
单击 | click |
双击 | doubleClick |
移动 | move,moveTo |
拖动 | drag,dragTo |
写英文段落 | write |
按键 | press |
按住按键 | hold |
按快捷键 | hotkey |
import pyautogui
pyautogui.position()
import pyautogui
x = 100
y = 100
button = 'left'
#(x,y)为单击坐标,button为鼠标左或右键点击('left' / 'right')
pyautogui.click(x,y,button = button)
import pyautogui
x = 100
y = 100
button = 'right'
#click()是单击指令,doubleClick()是双击指令,注意doubleClick中的第一个‘c’是大写字母
pyautogui.doubleClick(x,y,button = button)
import pyautogui
x = 100
y = 100
s = 2
#(x,y)为鼠标移动的目标坐标,s为移动时间(秒)
pyautogui.move(x,y,s)
import pyautogui
x = 100
y = 100
s = 2
button = 'left'
#move()是鼠标移动指令,drag()是鼠标按键拖动指令
pyautogui.drag(x,y,s,button = button)
import pyautogui
l = 10
#l为滚动格数
pyautogui.scroll(l)
import pyautogui
text = 'hello world'
interval = 0.25
#text为写的文字(仅支持英文),interval为按下每个按键后停留的时间
pyautogui.write(text,interval=interval)
import pyautogui
key = 'a'
#key 为要按下的按键
pyautogui.press(key)
import pyautogui
with pyautogui.hold('ctrl'):
pyautogui.press(['right','right','right'])
#先按住ctrl,再按三次right,再释放ctrl
import pyautogui
pyautogui.hotkey('ctrl','c') #按下 ctrl + c 组合键
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。