SadBunny Posted January 11, 2013 Share Posted January 11, 2013 Hi people! Haven't been on this forum for ages. Good to be back. I am writing an autoit script for colleagues who use multiple instances (windows) of a fullscreen sales application. It keeps track of which window is for which agent login, and lists those windows in a systray menu so users can taskswitch more easily. Since it is a fullscreen application I chose to do everything through the systray, to save on screen estate. The problem: the workstations have many programs running in the system tray and not very high screen resolution, so the system trays are in "hide inactive items" mode. Since the sales system is keyboard-intensive, having to switch hands to the mouse and clicking two times before they even reach the systray menu is somewhat bothersome. The solution I am looking for: a hotkey in the script that activates the systray menu of the script, so users don't have to peel open the system tray with that "show all icons" arrow before they reach the script tray icon. Possible alternative solution is to have a hotkey show a (to be made) custom popup window with buttons, but I'd like to keep using the systray. Oh, and another question: for tray items, it seems I have the choice between either checkbox items or radio control groups for the tray menu items. Not a big problem, I use radio buttons and it works kinda like a regular button, but, why can't they just be regular buttons like in every other application? Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 11, 2013 Moderators Share Posted January 11, 2013 SadBunny,This works for me - it shows all the hidden icons and then opens its own menu which you can activate via the keyboard (you said that is what you wanted): expandcollapse popup#include <GuiToolBar.au3> Global $hSysTray_Handle HotKeySet("q", "_Show") Opt("TrayMenuMode", 3) TrayCreateItem("One") TrayCreateItem("Two") TrayCreateItem("Three") TrayCreateItem("") $mExit_Item = TrayCreateItem("Exit") TraySetState() TraySetToolTip("TestScript") While 1 If TrayGetMsg() = $mExit_Item Then Exit WEnd Func _Show() $iSystray_ButtonNumber = Get_Systray_Index("TestScript") ; Put your traytip text here as before If @error Then MsgBox(16, "Error", "Icon not found in system tray") Exit EndIf $hTaskBarHandle = WinGetHandle("[Class:Shell_TrayWnd]", "") ControlClick($hTaskBarHandle, "", "[CLASS:Button; INSTANCE:1]") _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right") EndFunc ;==>_Show Func Get_Systray_Index($sText) ; Find systray handle $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]') If @error Then MsgBox(16, "Error", "System tray not found") Exit EndIf ; Get systray item count Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle) If $iSystray_ButCount = 0 Then MsgBox(16, "Error", "No items found in system tray") Exit EndIf ; Look for tooltip For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1 If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sText) > 0 Then ExitLoop Next If $iSystray_ButtonNumber = $iSystray_ButCount Then Return SetError(1, 0, -1) ; Not found Else Return $iSystray_ButtonNumber ; Found EndIf EndFunc ;==>Get_Systray_IndexI used the "q" HotKey to display the menu and set the tooltip to a pretty generic value - you can obviously change these to match your required values. It works nicely for me on Vista x32 when I set the Systray status to "Hide" for the exe. Does it for you? 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...
SadBunny Posted January 11, 2013 Author Share Posted January 11, 2013 (edited) Thanks for the fast and useful reply! It works pretty charmingly, except for one thing: after 'q' activates the menu, the mouse pointer disappears when mousing over the activated menu. Since I was looking for a keyboard-based solution anyway, it's probably not a biggie, but still, GUI-wise it looks&feels weird. Know anything about that? /edit: by the way, I am devving on a W7 x64 box here. Script will be used on XP x32. This GUI issue might be a windows quirk? Edited January 11, 2013 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 11, 2013 Moderators Share Posted January 11, 2013 SadBunny, Glad it works for you too. The mouse cursor is always visible for me over the activated menu, so I cannot really suggest anything about that - sorry. M23 SadBunny 1 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...
SadBunny Posted January 11, 2013 Author Share Posted January 11, 2013 Thanks a bunch anyway, your solution is very usable! And I learned something about directly interacting with windows system controls. Sweet! Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
JustSomeone Posted June 11, 2014 Share Posted June 11, 2014 This is bit old, but ill bump it instead of opening another thread. Running M23's example straightforward returns Icon not found in system tray OS win7 x64 & Autoit 3.3.10.2. The program runs smoothly, there is an icon in the tray and the menu on the icon is correct What can be wrong, since i don't understand this script (yet) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 11, 2014 Moderators Share Posted June 11, 2014 JustSomeone,I have just tested the above code on my Win7 x32 machine and it works, so I cannot suggest why it does not work for you. 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...
JustSomeone Posted June 11, 2014 Share Posted June 11, 2014 JustSomeone, I have just tested the above code on my Win7 x32 machine and it works, so I cannot suggest why it does not work for you. M23 It works, if the icon is shown, hoever if the icon is hidden (in that box that windows keep its icons) it does not work. Help please Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 11, 2014 Moderators Share Posted June 11, 2014 JustSomeone,I have spent the past few hours trying to find out how to access the hidden icons - alas without success. The change in Win 7 to the popup box has changed the whole systray model. But I will keep looking. 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...
junkew Posted June 11, 2014 Share Posted June 11, 2014 (edited) For me it works (at least at the systray box, not fully clear which box / classname you need for the popup one it seems to be nested) I was able to get the missing icon error but that is due to not changing this line $iSystray_ButtonNumber = Get_Systray_Index("TestScript") ; Put your traytip text here as before >Running:(3.3.12.0):C:Program Files (x86)AutoIt3autoit3.exe win7 64 bits But class is differently Title is: <NotificationOverflow> Class := <NotifyIconOverflowWindow> *** Parent Information *** Title is: <Bureaublad> Class := <#32769> so you have to tweak with this $hSysTray_Handle = ControlGetHandle('[Class:NotifyIconOverflowWindow]', '[Class:ToolbarWindow32;Instance:1]', '') Edited June 11, 2014 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 11, 2014 Moderators Share Posted June 11, 2014 junkew,Thanks for the hints - got it working now. JustSomeone,This script looks first in the main systray - if it does not find the icon it opens the popup and looks there:expandcollapse popup#include <GuiToolBar.au3> Global $hSysTray_Handle Global $sTipText = "TestScript" ; Change this to the text you require HotKeySet("q", "_Search") Opt("TrayMenuMode", 3) TrayCreateItem("One") TrayCreateItem("Two") TrayCreateItem("Three") TrayCreateItem("") $mExit_Item = TrayCreateItem("Exit") TraySetState() TraySetToolTip("TestScript") While 1 If TrayGetMsg() = $mExit_Item Then Exit WEnd Func _Search() $hTaskBarHandle = WinGetHandle("[Class:Shell_TrayWnd]", "") ; Find main systray handle and look there first $hSysTray_Handle = ControlGetHandle("[Class:Shell_TrayWnd]", "", "[Class:ToolbarWindow32;Instance:1]") If @error Then MsgBox(16, "Error", "System tray not found") Exit EndIf $iSystray_ButtonNumber = Get_Systray_Index($sTipText) If Not @error Then _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right") Exit EndIf ; Click on button to open hidden icons ControlClick($hTaskBarHandle, "", "[CLASS:Button; INSTANCE:1]") ; Wait for window and then get handle WinWait("[Class:NotifyIconOverflowWindow]") $hSysTray_Handle = ControlGetHandle("[Class:NotifyIconOverflowWindow]", "", "[Class:ToolbarWindow32;Instance:1]") If @error Then MsgBox(16, "Error", "System tray not found") Exit EndIf ; Now look in hidden icons $iSystray_ButtonNumber = Get_Systray_Index($sTipText) If @error Then MsgBox($MB_SYSTEMMODAL, "Error", "Could not find icon") Else _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right") Exit EndIf EndFunc ;==>_Show Func Get_Systray_Index($sText) ; Get systray item count Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle) If $iSystray_ButCount = 0 Then MsgBox(16, "Error", "No items found in system tray") Exit EndIf ; Look for tooltip For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1 If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sText) > 0 Then ExitLoop Next If $iSystray_ButtonNumber = $iSystray_ButCount Then Return SetError(1, 0, -1) ; Not found Else Return $iSystray_ButtonNumber ; Found EndIf EndFunc ;==>Get_Systray_IndexThat works fine for me - how about you? M23 mLipok 1 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...
junkew Posted June 11, 2014 Share Posted June 11, 2014 @Melba: Works good also on my machine Information was retrieved with the simpleSpy of the IUIAutomation thread (can spy on popups where I seem not be able to do that with AU3Inf) '?do=embed' frameborder='0' data-embedContent>> FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 11, 2014 Moderators Share Posted June 11, 2014 junkew, Works good also on my machineExcellent - thanks for letting me know. 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...
JustSomeone Posted June 12, 2014 Share Posted June 12, 2014 (edited) I will try it bit later, because now i have other alot more imporant things to do, and i will post feedback, thanks to all of you Edit: missing include #include <MsgBoxConstants.au3> Edited June 12, 2014 by JustSomeone Link to comment Share on other sites More sharing options...
EdWilson Posted June 3, 2017 Share Posted June 3, 2017 Melba32, wanting to say "Thank you". The code that you shared in this thread has been way helpful! Just a wee bit, it's helped hundreds of paramedics pay less attention to the technology, and more attention to their patient. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 3, 2017 Moderators Share Posted June 3, 2017 EdWilson, Thank you for having taken the trouble to post - you have no idea how happy I am to hear that I have helped these wonderful people in some way, however small. 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...
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