Sign in to follow this  
Followers 0
James

Minimize GUI to tray

5 posts in this topic

Hey,

If anyone ever needs this then here you go.

#include <Constants.au3>
#include <GUIConstants.au3>
#NoTrayIcon

Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)   

TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "Minimize")

$GUI = GUICreate("Minimize me", 460, 400)
GUICtrlCreateLabel("Press the minimize button to hide the window.", 125, 175)

GUISetState(@SW_SHOW)

While 1
    $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE
            Exit
        Case $iMsg = $GUI_EVENT_MINIMIZE
            GuiSetState(@SW_HIDE)
                        TraySetState(1)
    EndSelect
WEnd

Func Minimize()
    TraySetState(2)
    GuiSetState(@SW_SHOW)
EndFunc

-James

Share this post


Link to post
Share on other sites



i've change it just a bit for what i needed. thanks

; toggle show/hide by clicking tray icon
#include <Constants.au3>
#include <GUIConstants.au3>

Global $is_minimized = 0

Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)   

TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "Toggle")

$GUI = GUICreate("Minimize me", 460, 400)
GUICtrlCreateLabel("Toggle show/hide by clicking tray icon", 125, 175)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_MINIMIZE
            GuiSetState(@SW_HIDE)
            $is_minimized = 1
            debug("$is_minimized: " & $is_minimized)
    EndSwitch
WEnd

Func Toggle()
    If $is_minimized = 1 Then
        GuiSetState(@SW_SHOW)
        $is_minimized = 0
    Else
        GuiSetState(@SW_HIDE)
        $is_minimized = 1
    EndIf
    debug("$is_minimized: " & $is_minimized)
EndFunc

Func debug($a)
    ConsoleWrite(@SEC & " " & $a & @CRLF)
EndFunc

Share this post


Link to post
Share on other sites

Cool! Some APPZ Just need a minimize... :)

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