Jump to content
Sign in to follow this  
PartyPooper

Not sure why @SW_HIDE isn't working

Recommended Posts

PartyPooper

I'm using the following code to screen cap the foreground window but for some reason I can't seem to hide the Save As dialog box using the WinSetSate function. Anyone have a better way of doing this?

Func OnScreenCap()
    GUISetCursor(1, 1)
    WinActivate($WindowTitle)
    Send("!{PRINTSCREEN}")
    Run("mspaint.exe", "", @SW_HIDE)
    WinWait("untitled - Paint")
    Sleep(500)
    ControlSend("untitled - Paint", "", "", "^v")
    Sleep(500)
    ControlSend("untitled - Paint", "", "", "^s")
    WinWait("Save As", "")
    WinSetState("Save As", "", @SW_HIDE)
    Sleep(500)
    ControlSend("Save As", "", "Edit1", @ScriptDir & "\Screenshots\" & @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & @MIN & "-" & @SEC & ".bmp")
    ControlClick("Save As", "", "Button2")
    opt("WinTitleMatchMode", 2)
    WinClose(" - Paint")
    GUISetCursor(2, 0)
EndFunc

Thanks.

Share this post


Link to post
Share on other sites
PartyPooper

Thanks Nuffilein805.

It worked here too so I'll use it. Still would've liked to know why WinSetState didn't work. Maybe it has something to do with child windows?

Share this post


Link to post
Share on other sites
LxP

It worked here too so I'll use it. Still would've liked to know why WinSetState didn't work. Maybe it has something to do with child windows?

Odd... I use it on file dialogues without any trouble; in fact I tried that part of your code with Paint and all was well.

Share this post


Link to post
Share on other sites
LxP

does his code work at your pc?

Yep, it works without any major problems. My Paint toolbars are detached from the main window so they appear while the Paint window is hidden, but I don't think that's important enough to accommodate.

Share this post


Link to post
Share on other sites
PartyPooper

I've also had to modify the code slightly by adding Opt("WinTitleMatchMode", 1) because my main gui window kept disappearing (only left with a task bar icon) once the routine returned if I left Opt("WinTitleMatchMode", 2) active. My code now works fine with:

Opt("WinTitleMatchMode", 2)
    WinClose(" - Paint")
    Opt("WinTitleMatchMode", 1)

Took me hours to track it down because I thought the problem was in another part of my code. Not sure if this is a bug or how things are supposed to work.

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.