Python pyautogui 操作鼠标

import time
import os
import pyautogui

value = True;
try:
    while value:
        x, y = pyautogui.position()
        pos = "鼠标当前位置: {} , {}".format(str(x), str(y))
        print(pos)
        time.sleep(0.2)
        os.system('cls')
except KeyboardInterrupt:
    print("end...")

# 鼠标的绝对位置移动
# pyautogui.moveTo(x=303, y=86, duration=0.5)

# 鼠标的相对位置移动
# time.sleep(2)
# pyautogui.moveRel(xOffset=250, yOffset=0, duration=2)


# 鼠标绝对位置拖拽
# time.sleep(3)
# pyautogui.dragTo(295, 255, 1, button='left')

# 鼠标相对位置拖拽
# time.sleep(3)
# pyautogui.dragRel(xOffset=555, yOffset=0, duration=1)
# time.sleep(1)
# pyautogui.dragRel(xOffset=-500, yOffset=0, duration=1)


# 鼠标的点击
time.sleep(2)
# pyautogui.click(139, 1050, 1, duration=4, button='left')
# 鼠标双击 \三击
# pyautogui.doubleClick(139, 1050, interval=1, duration=3)
# pyautogui.tripleClick(78, 1046, interval=1, duration=3)

# 鼠标的按下 松开
# pyautogui.mouseDown(78, 1046, duration=3)
# pyautogui.mouseUp(78, 1046, duration=3)


# 鼠标滑轮滚动
# pyautogui.scroll(-1000)

# 鼠标的无规则运动
# 开始很慢,后面加速
# pyautogui.moveTo(100, 100, 2, pyautogui.easeInQuad)
# 开始很快,后面减速
# pyautogui.moveTo(200, 200, 2, pyautogui.easeOutQuad)
# 开始结束很快,中间很慢
# pyautogui.moveTo(100, 100, 2, pyautogui.easeInOutQuad)
# 一步一徘徊
# pyautogui.moveTo(100, 100, 2, pyautogui.easeInBounce)
# 幅度最大的
pyautogui.moveTo(100, 100, 2, pyautogui.easeInElastic)

你可能感兴趣的:(Python,python,计算机外设,开发语言)