fork(1) download
  1. import pyautogui
  2. pyautogui.FAILSAFE = True #要停止的時候移到畫面左上角
  3. pyautogui.size() #看螢幕解析度
  4. width,height=pyautogui.position() #取得位置position 會回傳 x,y 二個值依序導入 width height 又學到一個用法
  5. pyautogui.moveTo(width,height,duration=1) #滑鼠移到weight height的位置
  6. pyautogui.PAUSE=2 #暫停二秒
  7. pyautogui.click() #左鍵點擊
  8. pyautogui.typewrite('word') #鍵盤輸入 word
  9. pyautogui.press(['enter','tab']) #按一下enter 再按tab
  10. pyautogui.dragTo(width,height,duration=3) #拖曳滑鼠至width height的位置
  11. pyautogui.hotkey('altleft','tab') #熱鍵
  12. ## 找到圖片的位置,回傳圖形的範圍值
  13. print(pyautogui.locateOnScreen('/home/roger/Desktop/close.png'))
  14. a,b,c,d=pyautogui.locateOnScreen('/home/roger/Desktop/close.png')
  15. ## 取得中心點
  16. x,y=pyautogui.center((a,b,c,d))
  17. pyautogui.moveTo(x,y)
Runtime error #stdin #stdout #stderr 0.01s 27712KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
ImportError: No module named 'pyautogui'