Floppy Posted November 18, 2011 Share Posted November 18, 2011 Global $hello $test = TrayCreateItem("Test") While 1 $msg = TrayGetMsg() Select Case $msg = $test MsgBox(0, "", "Test") $hello = TrayCreateItem("Hello") Case $msg = $hello MsgBox(0, "", "Hello") EndSelect WEnd How can I prevent message "Hello" from displaying? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 18, 2011 Moderators Share Posted November 18, 2011 FSoft,Although you have declared the variable $hello, you have not given it a value - so AutoIt assumes it is 0. Guess what the default return frm GUIGetMsg is when there are no messages in the queue - you got it! So the Case fires every time. Solution: give the variable an intial placehoder value that will never fire! But you have another problem as well. You need to remove the default AutoIt tray items or you wil pause the script each time you click on the icon - then you can never click your "Test" trayitem. But if you remove them, you need to add your own "Exit" tray item - gets complicated doesn't it? Here is a little script which shows all that in action: ; Remove the default items Opt("TrayMenuMode", 3) ; Set a ridiculous value for this ControlID Global $hello = 9999 $test = TrayCreateItem("Test") $exit = TrayCreateItem("Exit") ; Add our exit item While 1 $msg = TrayGetMsg() Select Case $msg = $test MsgBox(0, "", "Test") $hello = TrayCreateItem("Hello") Case $msg = $hello MsgBox(0, "", "Hello") Case $msg = $exit ; And look for it here Exit EndSelect WEndAll clear? 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...
Floppy Posted November 18, 2011 Author Share Posted November 18, 2011 (edited) LOL Thank you Melba! Please can you give me a range of numbers that I can use to declare tray items? E.g. 99-99999 Edited November 18, 2011 by FSoft Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 18, 2011 Moderators Share Posted November 18, 2011 FSoft,a range of numbers that I can use to declare tray itemsYou are not declaring the value of the TrayItem - that is set when you use TrayCreateItem. What the 9999 represents is a placeholder value so that the variable holds something and does not fire when TrayGetMsg returns 0. Why do I use 9999? Well, ControlIds for normal GUI controls and TrayItems start around 3 and can go up to 65532 (or so they say!). I have never had more than 10000 controls in a GUI (in fact nowhere near that number! ) and so I felt that 9999 was pretty safe to use as it would be unlikely to match a real ControlID. If you look at the Managing Multiple GUIs tutorial in the Wiki you will see that I use it a lot in the example scripts for exactly the same reason. And you will also see that you can use the same value for all the placeholder values for the predeclared variables - it will be replaced by the real ControlID when the control is actually created. All clear now? 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...
Floppy Posted November 19, 2011 Author Share Posted November 19, 2011 Ok, thank you for your great explaination Melba! 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