问题
I know and have seen tons of documentations explaining about how to capture mouse movement within a given window using mouseclick events in opencv. What I want to know is that if is there a way to capture mouse movements (x,y co-ordinates) for the entire screen of my system.
Any link, documentation or code snippet will be really helpful to proceed me with the same.
回答1:
Depending on your OS, you can do that with pyautogui
like this:
#!/usr/bin/env python3
import time
import pyautogui
for i in range(10):
x, y = pyautogui.position()
print(f'Mouse position: x={x}, y={y}')
time.sleep(1)
来源:https://stackoverflow.com/questions/60882907/how-to-capture-mouse-movement-for-the-whole-window-in-opencv-python