Sign in to follow this  
Followers 0
Zachlr

Minimize and hide on GUI exit?

3 posts in this topic

I've seen many programs out there that will minimize the application to the task tray when the GUI is closed, and then come back when the tray item is clicked. Is there a feature built in to AutoIT3 for this? Can it be done by minimizing and then hiding (or just hiding for that matter) the window? I have tried

$nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUISetState(@SW_MINIMIZE, $LogViewer)
            GUISetState(@SW_HIDE, $LogViewer)
EndSwitch

but it doesn't seem to work. The GUI still closes, and I can't just create a new one because there are data in the controls that need to remain there.

The answer is probably right in front of me, but I'm not seeing it.

Thanks,

Zach

Share this post


Link to post
Share on other sites



Hope this is what you are looking:

#include <GUIConstants.au3>
#include <IE.au3>
#include <Constants.au3>
Opt("TrayOnEventMode",1)
Opt("TrayAutoPause",0)
$LogViewer = GUICreate('whatever',300,300)
guisetstate()
TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, "max")
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUISetState(@SW_MINIMIZE, $LogViewer)
            GUISetState(@SW_HIDE, $LogViewer)
    EndSwitch
Wend    

Func max()
    GUISetState(@SW_RESTORE, $LogViewer)
    GUISetState(@SW_SHOW, $LogViewer)
EndFunc

Share this post


Link to post
Share on other sites

Yep! Works like a charm. Thanks!

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  
Followers 0