1. 获取鼠标位置
import os,time
import pyautogui as pag
try:
while True:
print("Press Ctrl-C to end")
x,y = pag.position()
posStr="Position:"+str(x).rjust(4)+','+str(y).rjust(4)
print (posStr)
time.sleep(0.2)
os.system('cls')
except KeyboardInterrupt:
print ('end....')
2. 移动鼠标并点击
import time
import pyautogui
x,y = pyautogui.position()
posStr="Position:"+str(x).rjust(4)+','+str(y).rjust(4)
print (posStr)
x, y = 1000, 534
num_seconds = 2
time.sleep(8)
pyautogui.moveTo(x, y, duration=num_seconds)
time.sleep(3)
i = 60
while i:
i -= 1
time.sleep(5)
pyautogui.click()