Jump to content

CaptureWnd offscreen


Terenz
 Share

Recommended Posts

CaptureWnd of ScreenCapture UDF can't capture offscreen and i don't care. But i don't like the result of the output image, example with this script:

#include <ScreenCapture.au3>

Run("notepad.exe")
$hNot = WinWait("[CLASS:Notepad]")
WinMove($hNot, "", -180, 0, 300, 300) ; just for test of a window in offscreen position!
_ScreenCapture_CaptureWnd("Test.jpg", $hNot)
WinClose($hNot)

This is the image:

2k4ya9.jpg

With all that black background, instead i prefer something like this ( edited image )

atvjbc.jpg

The UDF use _WinAPI_GetDesktopWindow and _WinAPI_GetDC so probabily but i don't know how to do is possible to use region ( CreateRectRgn \ SetWindowRgn? ) to subtract the "un-visible" area for get the result like the second image. Please show me how to do, thanks :D

Or are welcome any suggestion

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

#include <ScreenCapture.au3>

Run("notepad.exe")
$hNot = WinWait("[CLASS:Notepad]")
WinMove($hNot, "", -180, 0, 300, 300)
Sleep(500)
_ScreenCapture_Capture("Test.jpg", 0, 0, -180 + 300, 300)
WinClose($hNot)

 

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

UEZ,

Thanks for the answer but don't take the example too serious :D

I'll clarify, the question is:

CaptureWnd for offscreen window add that ugly black background. Instead i want to have in the saved image only the visible part of the window. I have think to use region but that was just an idea. The expected result is the second image on the first post. Thanks again

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

That's what the code is doing. It captures only the visible part of the window.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Yes but with that code i can cover if the window is moved on the left, but if is offscreen on top-left, top-right, bottom, bottom-left, bottom-right and so on there are many situation. Regions wasn't a good idea? :sweating:

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

You can check for the coordinate of the window and check afterwards which part is off the screen. That shouldn't be a big deal.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Make a copy of CaptureWnd function and add a couple of new variable for check SM_CXSCREEN - $SM_CYSCREEN using _WinAPI_GetSystemMetrics. Than compare the original variable of the Window with that and if is > than use the value reported from GetSystemMetrics. In this case you have always a good image ;)

I don't know if it work in a multi monitor configuration, i don't have one. Maybe UEZ know.

Link to comment
Share on other sites

I've one in my office (3 screens). If I find a slot I will code a function.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...