获取鼠标位置
1 #先下载pyautogui库,pip install pyautogui 2 import os,time 3 import pyautogui as pag 4 try: 5 while True: 6 print("Press Ctrl-C to end") 7 x,y = pag.position() #返回鼠标的坐标 8 posStr="Position:"+str(x).rjust(4)+','+str(y).rjust(4) 9 print(posStr) #打印坐标 10 time.sleep(1) 11 #os.system('cls') 12 except KeyboardInterrupt: 13 print ('end....')

浙公网安备 33010602011771号