You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had some problems trying to capture the window of a game to do some Reinforcement Learning. The package I'm using uses win32gui to get the window and the size of that window. However, it wasn't getting the window size correctly, returning a cropped screenshot every time a frame was captured.
I had the same problem when testing this function with PyGetWindow and, though I couldn't find a solution for Pywin32, I found a solution for PyGetWindow and it applies for Pywin32 too. The solution is simply importing PyAutoGUI. I don't know why that happens, though, and since I couldn't find the solution for pywin32 through googling, I decided to post this here.
PS: I'm using an outdated version of pywin32. I don't know if I discovered a bug, if it's a known bug or if I just did something wrong.
Expected behavior and actual behavior.
Expected: Detect an application window size, which is about width=1015 and height=678 (obtained through sprite extraction) - offsets ignored.
Actual behavior: The application window has been correctly detected. However, the size detected was incorrect, which was width=816, height=544, x_offset=2 and y_offset=26, resulting in loss of necessary data.
Steps to reproduce the problem.
execute the desired application in window mode.
import win32gui;
assign win32gui.FindWindow(None, [application_window_name]) to a variable
call print(win32gui.GetClientRect(variable))
compare the output with the real width and height of such window (this can be done by taking a screenshot and selecting the window in Paint or thorugh a Sprite Detector - in my case, I used spritex==0.1.3)
Version of Python and pywin32: Python == 3.8.8 (Conda) || pywin32 == 227
pywin32 just wraps the win32 functions - it doesn't do any processing of the data returned from GetClientRect etc, so I suspect there's something else going on, possibly to do with DPI etc. You might like to follow the instructions at https://github.com/mhammond/pywin32#support, but I don't see any evidence of a pywin32 bug here.
I had some problems trying to capture the window of a game to do some Reinforcement Learning. The package I'm using uses win32gui to get the window and the size of that window. However, it wasn't getting the window size correctly, returning a cropped screenshot every time a frame was captured.
I had the same problem when testing this function with PyGetWindow and, though I couldn't find a solution for Pywin32, I found a solution for PyGetWindow and it applies for Pywin32 too. The solution is simply importing PyAutoGUI. I don't know why that happens, though, and since I couldn't find the solution for pywin32 through googling, I decided to post this here.
PS: I'm using an outdated version of pywin32. I don't know if I discovered a bug, if it's a known bug or if I just did something wrong.
Expected behavior and actual behavior.
Expected: Detect an application window size, which is about width=1015 and height=678 (obtained through sprite extraction) - offsets ignored.
Actual behavior: The application window has been correctly detected. However, the size detected was incorrect, which was width=816, height=544, x_offset=2 and y_offset=26, resulting in loss of necessary data.
Steps to reproduce the problem.
win32gui.FindWindow(None, [application_window_name])
to a variableprint(win32gui.GetClientRect(variable))
Version of Python and pywin32: Python == 3.8.8 (Conda) || pywin32 == 227
This problem seems to be solved when pyautogui is imported into the code
I've tried importing pyautogui since this method worked when dealing with PyGetWindow
The text was updated successfully, but these errors were encountered: