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

In method [_screenshot_xxx ];  Use param[region] error, causing larger screenshots #113

Open
lxk696 opened this issue Feb 13, 2024 · 1 comment

Comments

@lxk696
Copy link

lxk696 commented Feb 13, 2024

In method [_screenshot_xxx ];  Use param[region] error, causing larger screenshots

In the latest version of pyscreen。 win10 + python 3.11.5

The region obtained using the method[ win32gui.GetWindowRect ]

region = win32gui.GetWindowRect(edit_content_handle)
pyautogui.screenshot("target.jpg", region=region)

fix the method [ def _screenshot_win32(imageFilename=None, region=None): ]

code

return the screenshot img

region_large

but desired screenshot like this;

After modifying the _screenshot_win32 code, the following image can be obtained correctly

region_target

@Tukkel
Copy link

Tukkel commented Feb 25, 2024

This is how it is supposed to work according to the documentation. The win32gui.GetWindowRect function works differently and you have to fix it in your own code.

Something like this:
winRegion = win32gui.GetWindowRect(edit_content_handle)
pyautogui.screenshot("target.jpg", region=(winRegion[0], winRegion[1], winRegion[2]-winRegion[0], winRegion[3]-winRegion[1]))

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