python实时得到鼠标的位置

来源:互联网 发布:查找淘宝用户购买记录 编辑:程序博客网 时间:2024/05/22 13:07
#先下载pyautogui库,pip install pyautoguiimport os,timeimport pyautogui as pagtry:    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....'

这里写图片描述