Jump to content
Sign in to follow this  
Regency

Setting up a minimize to try func

Recommended Posts

Regency

I cant seem to figure out if there even is a finction in the GUI interface to do this. Anyone know something i dont... example script please if u know how to do this

Share this post


Link to post
Share on other sites
Richard Robertson

If you want to minimize to the tray, you need to hide the window, then set up your own menu or click handler for the tray icon.

Share this post


Link to post
Share on other sites
smashly

Hi, on event example...

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

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

;---Gui
$Gui = GUICreate("Example Min to Tray", 260, 200, -1, -1, -1, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_MINIMIZE, "GuiEvent", $Gui)
GUISetOnEvent($GUI_EVENT_CLOSE, "GuiEvent", $Gui)
GUISetState(@SW_SHOW, $Gui)

;---Tray
$TrayRestore = TrayCreateItem("Restore Gui")
TrayItemSetOnEvent(-1, "TrayEvent")
TrayCreateItem("")
$TrayExit = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "TrayEvent")
TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, "TrayEvent")
TraySetClick(16)

While 1
    Sleep(100)
WEnd    

Func GuiEvent()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_MINIMIZE
            GUISetState(@SW_HIDE, $Gui)
            TraySetState(1)
            TraySetToolTip("Left click to Restore Gui." & @LF & "Right click to Restore or Exit Gui.")
    EndSwitch
EndFunc 

Func TrayEvent()
    Switch @TRAY_ID
        Case $TrayRestore, $TRAY_EVENT_PRIMARYDOWN
            TraySetState(2)
            GUISetState(@SW_SHOW, $Gui)
        Case $TrayExit
            Exit
    EndSwitch
EndFunc

Cheers

Share this post


Link to post
Share on other sites
Madza91

This is better ;)

#include <GUiconstants.au3>
#include <Constants.au3>

Opt("TrayMenuMode",1)
Opt("TrayAutoPause",0)
TraySetClick(16)

$min=False
$Main=GUICreate("")
GUISetState()
;Tray Menu
$Show=TrayCreateItem("Show/Hide")
TrayItemSetState(-1,$TRAY_DEFAULT)
$Quit=TrayCreateItem("Quit")

While 1
    $gMsg=GUIGetMsg()
    Switch $gMsg
    Case $GUI_EVENT_CLOSE
        _Hide_Show()
    Case $GUI_EVENT_MINIMIZE
        _Hide_Show()
    EndSwitch
    $tMsg=TrayGetMsg()
    Switch $tMsg
    Case $Show
        _Hide_Show()
    Case $Quit
        Exit
    EndSwitch
WEnd
    

Func _Hide_Show()
    If $min Then
        GUISetState(@SW_SHOW,$Main)
        GUISetState(@SW_RESTORE,$Main)
        $min=False
    Else
        Guisetstate(@SW_MINIMIZE,$Main)
        Guisetstate(@SW_HIDE,$Main)
        $min=True
    EndIf
EndFunc;==>Hide_Show

Left double click on tray icon to Shoe/Hide or on close and minimize... :P


[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Share this post


Link to post
Share on other sites
dani

This is better :)

~code~

Left double click on tray icon to Shoe/Hide or on close and minimize... ;)

Please use the [ autoit ] and [/ autoit ] tags when posting AutoIt code :P Edited by D4ni

Share this post


Link to post
Share on other sites
Madza91

Shut up d4nI

:P

Edited by n3nE

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

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  

×