Jump to content
FrancescoDiMuro

[Solved] _ScreenCapture_CaptureWnd captures my GUI too

Recommended Posts

FrancescoDiMuro
Posted (edited)

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

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
mikell
7 hours ago, FrancescoDiMuro said:

I made a GUI which through I fire the event "Capture"

Which way does this gui work ? do you press a button ? :)

Share this post


Link to post
Share on other sites
FrancescoDiMuro

Good morning @mikell:)
Yes, I just have a file menu and a button on this GUI ( which takes the picture ) :)
Thanks for the reply :)

Best Regards.


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
mikell

So you're coming into trouble, because pressing the button makes your gui the current active window  :)
 

Share this post


Link to post
Share on other sites
FrancescoDiMuro

@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

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
mikell

So the only workaround I can think of would be : hide the gui, take the picture, show the gui  :D

Share this post


Link to post
Share on other sites
FrancescoDiMuro
15 hours ago, mikell said:

So the only workaround I can think of would be : hide the gui, take the picture, show the gui  :D

Already tried! Seems to not work :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
mikell

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

 

Share this post


Link to post
Share on other sites
FrancescoDiMuro

@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

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
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

  • Similar Content

    • MFrancisca
      By MFrancisca
      Hello! 
      I've been checking the logging UDFs in the wiki, mostly Log4a and Loga and I wanted to ask which one would you recommend for a script that will be executed remotely through PSExec. My main question is where the logs are located in that situation and if I can change that location to a custom one., because I need to retrieve them at the end of execution.
      So in a rough description the process is
      Open PSExec
      Send compiled AutoIT script to remote machine
      Execute script
      Copy logs from the remote to the local machine.
       
      Any opinions? 
    • caramen
      By caramen
      I watched _OL_ItemSend&_OL_ItemFind&_OL_ItemCreate in OutlookEx UDF but hmmm
       
      Since it use the test environnement i cant get the orders of the mail creation
       
      Can someone make me win some time of reading all exemples script and lead me how to do one ?
      That whould be lovely.
      Gnight
    • Tersion
      By Tersion
      Here the this wiki page with list of available UDFs for data compression. For my tasks I only need ZIP support, so I started looking at pure AutoIt UDFs without any 3rd party dlls. And found out that most of available realizations uses standard ("native method") Windows dll - "zipfldr.dll". So for now I chose ZIP UDF by wraithdu. I've tested it on Windows 7 (x64) and it seem works fine. But here the comment from another topic where user says that Windows 10 discontinued support of "zipfldr.dll". Now I confused. I don't have around any Windows 10 machine to tested it. So maybe someone could confirm or deny that? Or maybe would better to switch to UDF with 7zip dll?
      I need an advice...
    • TheSaint
      By TheSaint
      Here is the bare bones of a UDF I have started work on.
      Mostly just a proof of concept at this stage, and still need to add some functions and dress the UDF up a bit ... to look like a UDF ... though it has my own distinct styling, especially as I have never really developed a UDF before now .... used plenty and modified plenty though. I've even invented my own UDF variable naming convention, which I am sure some of you will be aghast at. I work with what feels best for me, but others are free to adapt if they wish.
      The idea is to emulate the simplicity of INI files, but gain the benefits of SQL.
      Two scripts are provided.
      (1) The UDF, a work in progress - SimpleSQL_UDF.au3
      (2) An example or testing script - UDF_Test.au3
      Another first for me, is creating a 2D array from scratch, never done that before, that I can recall ... never had a need, and even for 1 dimension arrays, for a long time now, I have just used _StringSplit to create them. So I needed a bit of a refresher course, which my good buddy @TheDcoder assisted me with ... not without some angst I might add. LOL
      SimpleSQL_UDF.zip  (12 downloads previously)
      (I have now completed all the functions I intended to. My next update will be a big improvement, bringing things more inline with my latest INItoSQL DB program changes.)
      Program requires the sqlite3.dll, not included, but easily enough obtained.
      Hopefully the usage is self-evident ... just change the Job number variable in the UDF_Test.au3 file to check the existing functions out.
      Enjoy!
      P.S. This is also related to a new program I have just finished and uploaded - INItoSQL DB
    • bbProg
      By bbProg
      Hi,
       
      how can I wait activate for windows with information as in the photos attached?
      Class is not being recognized by the script.
       
      thanks in advanced.



×