1

using opencv I am able to detect an object in a game. However, when my mouse moves over to the coordinate (in the actual game window), its using absolute coordinate (based on monitor pixel). So when I move my actual game window, its no longer clicking at the right spot.

Is there a way to move the mouse within the game window? For example, say if my game window is 500x500, and rectangles is detected say at (100, 100), is there a way to mouse over (100,100) relative to the game window? because if I move my game screen, I still want my mouse to be able to move to the same location.

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
wew044
  • 49
  • 6
  • figure out where the window is, then add/subtract... – Christoph Rackwitz Jun 21 '22 at 12:53
  • is this the only way? is there a way to translate the same coordinate to the active window, like using relative instead of absolute? – wew044 Jun 23 '22 at 00:10
  • that is exactly what I meant. "translate" means add/subtract. – Christoph Rackwitz Jun 23 '22 at 07:53
  • got it. appreciate the response! – wew044 Jun 23 '22 at 23:52
  • I understood your question OP - you're looking for something like Mouse Coords Relative in AHK which would allow you to simply specify the coordinates of the active / focused window. It seems as if there is no native method for python to move mouse coords based on active window, according to my research. This is very strange though. – Klh Nov 16 '22 at 18:29
  • I wasnt able to find anything either, i had to just translate it as @christoph suggested – wew044 Dec 03 '22 at 02:02

0 Answers0