利用python控制鼠标自动移动,在windows画板中自动画图。

import pyautogui,time
time.sleep(5)
pyautogui.click()   # click to put drawing program in focus
distance = 200
while distance > 0:
    pyautogui.dragRel(distance,0,duration = 0.2)  #move right
    distance = distance - 5
    pyautogui.dragRel(0,distance,duration = 0.2)  # move down
    pyautogui.dragRel(-distance,0,duration = 0.2) # move left
    distance = distance -5
    pyautogui.dragRel(0,-distance,duration = 0.2)  # move up
    

效果图如下:
利用python控制鼠标自动移动,在windows画板中自动画图。_第1张图片

你可能感兴趣的:(python方法)