# 鼠标左键返回当前鼠标位置的小程序 import win32api import win32gui import time state_left = win32api.GetKeyState(0x01) # Left button down = 0 or 1. Button up = -127 or -128 boolean = True while boolean: a = win32api.GetKeyState(0x01) if a != state_left: # Button state changed x,y = win32api.GetCursorPos() print("鼠标当前位置坐标为:%d,%d"%(x,y)) boolean = False time.sleep(0.001)