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

    • 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
      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.



    • xtcislove
      By xtcislove
      Hello,
      as a start in Autoit i tried something i was missing since im using Autoit. 

      I build a custom MessageBox which has a large amount of custom options and which scales its size on the parameters you set. 

      Aviable Settings:
      -Title
      -Unlimited Buttons
      -Text Color (Buttons, Text)

      -Background Color (Msgbox, Buttons, Label) 

      -Button Timeout
      -Autoclose Timeout
      -Icon (Default, No Icon, Custom)

      -Label/ Button Style. 
      -Transparency

      I tried to keep this as close as i could to a Msgbox i was used too on my batch times.

      After i was ready i realised, @Melba23 probably build a way better msgbox which would have suit my needs enterly, anyway thanks to @Melba23 because i use his Stringsize UDF. 

       
       
      local $Message = _sMsgBox("Test", 6, "Continue?") if @extended <> -1 Then MsgBox(0, @extended, $Message&" Button pressed")  
      ScalingMessageBox.au3
    • Gowrisankar
      By Gowrisankar
      Dear members, 
      I am working on a project where, emails from outlook are to be read and moved to various folders within the mailbox, based on the content of the emails.
      I used the below code for moving mails. It works fine when I run it against individual mail ids. But when I run it on Shared mailbox, the mails are not moved to respective folders.
      _OL_ItemMove($oOutlook, $sEntryId, Default, $sDestinationFolder) The value of $sEntryId is saved in an excel report initially. The current process reads the $sEntryId from the excel and passes it to "_OL_ItemMove" statement.
      Requesting the guidance of the forum members in this issue.
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening everyone
      I am working with Word UDF ( thanks @water! ), and, especially, with the function _Word_DocFindReplace().
      The replace does work everywhere in the document, but, it does not work in Headers or Footers.
      Am I missing something or am I forced to use the code below?
      I have already looked in the Help file ( about _Word_DocFindReplace() ), but there are no mentions about replace text in Headers/Footers.
      Sub FindAndReplaceFirstStoryOfEachType() Dim rngStory As Range For Each rngStory In ActiveDocument.StoryRanges With rngStory.Find .Text = "find text" .Replacement.Text = "I'm found .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll End With Next rngStory End Sub Thanks everyone in advance


      Best Regards.
×