Jump to content

[Solved] _ScreenCapture_CaptureWnd captures my GUI too


Recommended Posts

Good morning everyone :)

I was playing a little bit with "Screen Capture" UDF, and I was trying to make a "Window" capture, but, since I made a GUI which through I fire the event "Capture", my GUI is captured as well, and I don't want to :)

This is the line of code that makes the capture:
 

_ScreenCapture_CaptureWnd($strScreenCaptureFileName, $objActiveWindow, 0, 0, -1, -1, False)

And these are the lines of code which select the "active" window:
 

Local $objCurrentWindow = 9999

If _IsPressed("01") Then
    $objCurrentWindow = WinGetHandle("[ACTIVE]")
    If $objCurrentWindow <> $objMyGUI Then  
        $objActiveWindow = $objCurrentWindow
    EndIf
EndIf

Sorry If I made stupid mistakes :)
Thanks in advance.

Francesco

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

@mikell
Not really :)

The code 

Local $objCurrentWindow = 9999

If _IsPressed("01") Then
    $objCurrentWindow = WinGetHandle("[ACTIVE]")
    If $objCurrentWindow <> $objMyGUI Then  
        $objActiveWindow = $objCurrentWindow
    EndIf
EndIf

avoid this, but, when I have my GUI in the same "section" of the screenshot, it is included in the screenshot :)
If I put my GUI on my second screen, the screenshot doesn't have my GUI in it :)

PS: I see this code from a @Melba23 post :) Thank you Sir! :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Hmmm this works for me

#include <ScreenCapture.au3>
#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Screen Capture")
$btn = GUICtrlCreateButton("test", 120, 170, 85, 25)
GUISetState(@SW_SHOW)
    
While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $btn
               GUISetState(@SW_HIDE)
               $objCurrentWindow = WinGetHandle("[ACTIVE]")
               _ScreenCapture_CaptureWnd(@desktopDir & "\GDIPlus_Image.jpg", $objCurrentWindow)
              GUISetState(@SW_SHOW)
        EndSwitch
WEnd

 

Link to comment
Share on other sites

@mikell

Using 

On 9/5/2018 at 12:02 PM, FrancescoDiMuro said:

_ScreenCapture_CaptureWnd($strScreenCaptureFileName, $objActiveWindow, 0, 0, -1, -1, False)

instead of 

31 minutes ago, mikell said:

_ScreenCapture_CaptureWnd(@desktopDir & "\GDIPlus_Image.jpg", $objCurrentWindow)

causes the "error".
I removed all the "extra" parameters, and now it works perfectly.

Thanks for your help :)

Best Regards.

 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

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

×
×
  • Create New...