Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autopy.mouse.location() uses different coordinates on first call only #61

Open
scholtes opened this issue Jun 11, 2020 · 0 comments
Open

Comments

@scholtes
Copy link

scholtes commented Jun 11, 2020

On some monitors, the first call of autopy.mouse.location() can return a different set of coordinates on the first call than all subsequent calls, which remain consistent.

Reproduction steps

  1. Move mouse to lower right corner
  2. Run the following code in a new instance of Python
from autopy import mouse as ms
def try5():
    print(ms.location())
    print(ms.location())
    print(ms.location())
    print(ms.location())
    print(ms.location())

try5()
  1. Observe output

*Note: I am not sure whether the issue will arise on all monitors and all settings. Try with different monitors and different resolution settings. My test was performed on a 1920x1080 monitor set to the recommended resolution. This was tested on Windows 10, latest autopy version as of the date this issue was created, python 3.7.

Problem

On my machine, this is the output from running the above:

(1228.0, 690.4)
(1535.2, 863.2)
(1535.2, 863.2)
(1535.2, 863.2)
(1535.2, 863.2)

Expected result should be that all 5 rows return the same tuple. My monitor is a 1920x1080 monitor and set to the recommended resolution so I would also expect the returned tuple to be (1919.0, 1079.0). I am not sure where the coordinate systems above are coming from. Also note the first result and the next 4 results are off by a factor of around 1.25, and those next 4 results are off from the expected 1920x10 by another factor of 1.25. That is, 1535 / 1228 = 1.25 and 1919 / 1535.2 = 1.25.

For example, using comparable libraries:

import pyautogui
import win32api
def things():
    print(pyautogui.position())
    print(win32api.GetCursorPos())

things()

returns

Point(x=1919, y=1079)
(1919, 1079)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant