learncodebygaming / pydirectinput

Python mouse and keyboard input automation for Windows using Direct Input.
Other
510 stars 90 forks source link

Breaks after a screenshot #56

Open cristopolis opened 1 year ago

cristopolis commented 1 year ago

Running a screenshot using something like mss (https://github.com/BoboTiG/python-mss)

with mss.mss() as sct:
     return sct.grab(region)

will offset all the x and ycoordinates for things such as moveTo(x,y) to a different spot on the monitor, and it remains that way until the .py file is done.

The size() always returns 3840x2160 correctly, but its position is initally squashing screensize somehow, and then reverting to the actual dimensions after I screenshot. Here is an example of using position() before and after:

Out[]:
  pos = (2559, 1439)
  took a screenshot
  pos = (3839, 2159)

By taking an arbitrary screenshot to set the offset before calling input, I can circumvent this issue, but I am curious if there is a way to prevent this from occurring.