Jump to content

Not sure why @SW_HIDE isn't working


PartyPooper
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.

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