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

PyGetWindow returns wrong location #26

Open
swadeeshs opened this issue May 4, 2020 · 1 comment
Open

PyGetWindow returns wrong location #26

swadeeshs opened this issue May 4, 2020 · 1 comment

Comments

@swadeeshs
Copy link

Here is my simple code to locate the Notepad++ opened on my screen. (Windows10)
import pygetwindow
window_name = 'new 1 - Notepad++'
window = pygetwindow.getWindowsWithTitle(window_name)[0]
print(window.topleft)
Output when executed>>Point(x=830, y=250)

The same code returns a different set of coordinates when I import PyAutoGUI. Here is the code and the output.
import pygetwindow
import pyautogui
window_name = 'new 1 - Notepad++'
window = pygetwindow.getWindowsWithTitle(window_name)[0]
print(window.topleft)
Output when executed>>Point(x=1038, y=312)

@Martyn0324
Copy link

Martyn0324 commented Oct 16, 2021

Hey! I was having a similar issue, but not only with PyGetWindow but also with win32gui from pywin32.

I was trying to extract a game window size, which I know for sure it's more or less width=1015 and height=678 (I used a sprite extractor).
However, PyGetWindow was returning width=821 and height=572, while win32gui was returning width=816 and height=544.

Upon seeing your issue, I installed pyautogui and imported it. Then PyGetWindow started to return width = 1026 and height = 715, while win32gui returned width=1020 and height = 680.

There might be a bug within PyGetWindow and win32gui that is fixed with the installation of pyautogui or some of its complements.

The code:

import pyautogui
import pygetwindow

teste = pygetwindow.getWindowsWithTitle('Jigoku Kisetsukan: Sense of the seasons v.1.09')[0]

print(teste.size)

import win32gui

window = win32gui.FindWindow(None, 'Jigoku Kisetsukan: Sense of the seasons v.1.09')

A screenshot of the situation, in case someone gets curious:
PS: The screenshot was taken before the fix. I took it to use it in my sprite extractor.
Teste

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

2 participants