Reputation: 67
Okay, so I'm using Pygame, and I created a code that tracks the mouse on my Pygame display. However, when I pull up another window over the Pygame one, it stops tracking the mouse position. I was wondering, is there any way to continue tracking the mouse even when my Pygame window is not the active one?
Upvotes: 2
Views: 92
Reputation: 67
Okay, so I figured it out. I was going about it the wrong way.
pygame.mouse.get_pos()
is what I was using, and that only tracks the position of the mouse on the Pygame surface created. So if there's another window there, the mouse isn't actually on the Pygame surface. I ended up installing the module "win32api" and using
import win32api
mouse = win32api.GetCursorPos()
x1 = mouse[0]
y1 = mouse[1]
for the x and y coordinates of the mouse position on the computer display. I realized afterward that there were questions answering what I needed to know, I just wasn't asking quite the right question.
Upvotes: 1