StungStang Posted March 24, 2011 Share Posted March 24, 2011 (edited) Hi to all, i want to have an option in my application that allow to enable or disable the tray menu when i minimize the programm... Here is my code to show what i want to do expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Form1", 259, 76, 284, 388) $Button1 = GUICtrlCreateButton("", 8, 8, 75, 25) $Button2 = GUICtrlCreateButton("Try Func", 88, 32, 75, 25) $Button3 = GUICtrlCreateButton("Try Func 2", 168, 8, 75, 25) GUISetState(@SW_SHOW) If IniRead (@ScriptDir & "\Setup.ini","Main","Tray","") = "" Then IniWrite (@ScriptDir & "\Setup.ini","Main","Tray","False") ElseIf IniRead (@ScriptDir & "\Setup.ini","Main","Tray","") = "False" Then GUICtrlSetData ($Button1, "Enable Tray") ElseIf IniRead (@ScriptDir & "\Setup.ini","Main","Tray","") = "True" Then GUICtrlSetData ($Button1, "Disable Tray") EndIf Opt("TrayAutoPause", 0) Opt("TrayMenuMode", 11) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_MINIMIZE If IniRead (@ScriptDir & "\Setup.ini","Main","Tray","") = "True" Then ;Create and show the tray menu Else ;Hyde Tray Menu EndIf Case $Button1 If IniRead (@ScriptDir & "\Setup.ini","Main","Tray","") = "False" Then IniWrite (@ScriptDir & "\Setup.ini","Main","Tray","True") GUICtrlSetData ($Button1, "Disable Tray") ElseIf IniRead (@ScriptDir & "\Setup.ini","Main","Tray","") = "True" Then IniWrite (@ScriptDir & "\Setup.ini","Main","Tray","False") GUICtrlSetData ($Button1, "Enable Tray") EndIf Case $Button2 ConsoleWrite ("It's only an example" & @CRLF) Case $Button3 ConsoleWrite ("It's only an example" & @CRLF) EndSwitch WEnd How i can do that?...if the tray menu option is on enable i want to create a tray menu...else i dont want the tray menu Hi! Edited March 24, 2011 by StungStang Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 24, 2011 Moderators Share Posted March 24, 2011 StungStang,Use TraySetClick(0) to disable your tray menu when a $GUI_EVENT_MINIMIZE event occurs - and then reset it to whatever you require when you see a $GUI_EVENT_RESTORE event. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
StungStang Posted March 24, 2011 Author Share Posted March 24, 2011 (edited) @Melba23I want create a tray menu if a $GUI_EVENT_MINIMIZE event occurs and the flag "main" is set to True...as i can see on help file TraySetClick(0) Sets the clickmode of the tray icon...Hi EDIT:I've fixed my problem with the function TraySetState ..., but i've another problem...i want activate (give the focus) on the main gui when i press "Return To GUI"...i try with WinActivate but don't work...this is my code:expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Form1", 259, 76, 284, 388) $Button1 = GUICtrlCreateButton("", 8, 8, 75, 25) $Button2 = GUICtrlCreateButton("Try Func", 88, 32, 75, 25) $Button3 = GUICtrlCreateButton("Try Func 2", 168, 8, 75, 25) GUISetState(@SW_SHOW) If IniRead (@ScriptDir & "\Setup.ini","Main","Tray","") = "" Then IniWrite (@ScriptDir & "\Setup.ini","Main","Tray","False") ElseIf IniRead (@ScriptDir & "\Setup.ini","Main","Tray","") = "False" Then GUICtrlSetData ($Button1, "Enable Tray") ElseIf IniRead (@ScriptDir & "\Setup.ini","Main","Tray","") = "True" Then GUICtrlSetData ($Button1, "Disable Tray") EndIf Opt("TrayAutoPause", 0) Opt("TrayMenuMode", 11) ;##################################################################### $TrayeExit = TrayCreateItem("Exit") $TrayReturn = TrayCreateItem("Return To GUI") $Traymessage = TrayCreateItem("Example") TraySetState (2) ;##################################################################### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_MINIMIZE If IniRead (@ScriptDir & "\Setup.ini","Main","Tray","") = "True" Then TraySetState () GUISetState(@SW_HIDE) Else TraySetState (2) EndIf Case $Button1 If IniRead (@ScriptDir & "\Setup.ini","Main","Tray","") = "False" Then IniWrite (@ScriptDir & "\Setup.ini","Main","Tray","True") GUICtrlSetData ($Button1, "Disable Tray") ElseIf IniRead (@ScriptDir & "\Setup.ini","Main","Tray","") = "True" Then IniWrite (@ScriptDir & "\Setup.ini","Main","Tray","False") GUICtrlSetData ($Button1, "Enable Tray") EndIf Case $Button2 ConsoleWrite ("It's only an example" & @CRLF) Case $Button3 ConsoleWrite ("It's only an example" & @CRLF) EndSwitch Switch TrayGetMsg () Case $TrayeExit Exit Case $TrayReturn GUISetState(@SW_SHOW) WinActivate ($hGUI) ;It don't work it dont give the focus on main gui Case $Traymessage ConsoleWrite ("It's only an example" & @CRLF) EndSwitch WEnd Edited March 24, 2011 by StungStang Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 24, 2011 Moderators Share Posted March 24, 2011 StungStang,I want create a tray menu if a $GUI_EVENT_MINIMIZE event occurs and the flag "main" is set to TrueDo not create the menu each time - just create the menu when you create the GUI and by using TraySetClick only allow it to be actioned when the main GUI is minimized and your flag is set. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
StungStang Posted March 24, 2011 Author Share Posted March 24, 2011 yes...se the post above your Hi! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 24, 2011 Moderators Share Posted March 24, 2011 StungStang,That is because you need to RESTORE the GUI from its minimized state: Case $TrayReturn GUISetState(@SW_SHOW) GUISetState(@SW_RESTORE)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
StungStang Posted March 24, 2011 Author Share Posted March 24, 2011 Thanks a lot, problem fixed Hi, StungStang Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now