美文网首页
python pyautogui 自动化

python pyautogui 自动化

作者: 王宣成 | 来源:发表于2020-07-18 19:26 被阅读0次
#! python3
import pyautogui

# 屏幕分辨率
print(pyautogui.size())

# 模拟鼠标点击
pyautogui.click(10,5)

# 鼠标滚动
pyautogui.scroll(200)
pyautogui.scroll(-200)

# 鼠标拖动
pyautogui.dragRel(200,0,duration=0.2) # 向右
pyautogui.dragRel(-200,0,duration=0.2) # 向左
pyautogui.dragRel(0,200,duration=0.2) # 向下
pyautogui.dragRel(0,-200,duration=0.2) # 向上

# 鼠标按键
pyautogui.typewrite(['a','b','left','right','X','y'])
pyautogui.typewrite('hello')

# 截图并获取坐标颜色值
im = pyautogui.screenshot('submit.png')
print(im.getpixel((0,0)))

# 获取截图中心位置并点击
s = list(pyautogui.locateOnScreen('submit.png'))
pyautogui.center(s)
pyautogui.click()

相关文章

网友评论

      本文标题:python pyautogui 自动化

      本文链接:https://www.haomeiwen.com/subject/ukyrkktx.html