python實時獲取鼠標在桌面的位置

安裝模塊:

pip install pyautogui
import os,time
import pyautogui as pag
while True:
      print "Press Ctrl-C to end"
      x,y = pag.position()
      pos="Position:"+str(x).rjust(4)+','+str(y).rjust(4)
      print pos
      time.sleep(0.3)
      os.system('cls')
print 'ending....'


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章