from pynput import mouse
from win32gui import GetWindowText, GetCursorPos, WindowFromPoint
def on_move(x, y):
print(GetWindowText(WindowFromPoint(GetCursorPos())))
# Collect events until released
with mouse.Listener(on_move=on_move) as listener:
listener.join()
1条答案
按热度按时间zwghvu4y1#
在Python中使用pynput和win32 api:(对我来说很好用!)
不要忘记安装:
pip install pynput
和pip install win32gui