1

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.

Shivam Sahil
  • 4,055
  • 3
  • 31
  • 62

1 Answers1

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)
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432