JohnSAutoIt Posted February 6, 2010 Share Posted February 6, 2010 Tray icons often carry more information than the process name. I want to be able to go to a tray icon using a partial name and read back the full text title of the icon (what is visible in the tooltip). Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 6, 2010 Moderators Share Posted February 6, 2010 JohnSAutoIt,Welcome to the AutoIt forum. When you post here it always helps if you have had a go at solving your problems beforehand. Having some code to work on is a great help - and no-one here is too keen to help the "code it for me" brigade.But as I have the code to hand and am feeling generous tonight - here you go: expandcollapse popup; The script is not foolproof - I have found that using the first word/words of the tooltip text gives the best results. #Include <GuiToolBar.au3> Global $sToolTipTitle = "" ; <<<<<<<<<<<<<<<< Enter some tooltip text for the icon you want here Global $iSystray_IconText = Get_Systray_IconText($sToolTipTitle) If @Error Then MsgBox(16, "Error", "Icon not found in system tray") Exit Else MsgBox(0,"Found", $iSystray_IconText) EndIf Exit ;............ Func Get_Systray_IconText($sToolTipTitle) ; Find systray handle Local $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 wanted tooltip Local $iSystray_ButtonNumber For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1 Local $sText = _GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber) If StringInStr($sText, $sToolTipTitle) = 1 Then Return $sText Next Return SetError(1, 0, "") EndFuncIf anything is unclear, please ask. 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...
JohnSAutoIt Posted February 6, 2010 Author Share Posted February 6, 2010 Thanks for the code. I wasn't expecting anyone to do it, I was looking for pointers. Having exhausted all the Tray commands I eventually found that the tray was basically a toolbar. I ended up in the area of your code, perhaps not as bullet-proof. I got results but have some buttons that can't be found whatever is entered as a partial. Investigating. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 6, 2010 Moderators Share Posted February 6, 2010 JohnSAutoIt,Sorry if I came across as tetchy, it was the "I want" in the original post that had that effect! What is the text you are looking for in the traytip? And what "snippet" does not find the full text? I did warn that the code is not foolproof, but it usually works. 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...
wraithdu Posted February 6, 2010 Share Posted February 6, 2010 You could try some functions from my UDF here: http://www.autoitscript.com/forum/index.php?showtopic=103871 Not sure if your results would be any different from Melba23's example though. Link to comment Share on other sites More sharing options...
JohnSAutoIt Posted February 7, 2010 Author Share Posted February 7, 2010 The script only works with the first part of the string as the search string. To be more generic: If StringInStr($sText, $sToolTipTitle) = 1 Then Return $sText should be If StringInStr($sText, $sToolTipTitle) > 0 Then Return $sText I guess it depends what you are after. The "start of string only" may be a bit safer in getting the correct button with short search strings. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 7, 2010 Moderators Share Posted February 7, 2010 JohnSAutoIt,Thank you for that - it explains the "I have found that using the first word/words of the tooltip text gives the best results" comment I added.I do not know how many times I have looked at that snippet and wondered why it was not working as I wanted it. Just takes another pair of eyes - peer review is a wonderful thing! Thank you again - I hope I helped you as much as you have just helped me! 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...
JohnSAutoIt Posted February 7, 2010 Author Share Posted February 7, 2010 It had me fooled at first. You get so used to seeing 1=success 0=fail. Link to comment Share on other sites More sharing options...
willichan Posted May 19, 2010 Share Posted May 19, 2010 Func Get_Systray_IconText($sToolTipTitle) I went through docs and Google searches until I was getting bleary-eyed, then finally found your solution. This works great! The only way to get status from one of our security apps at the office is from the tray icon text. Your solution gave me the means I needed. Big thanks! My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 20, 2010 Moderators Share Posted May 20, 2010 willichan, Glad I could help - even if I did not realise it at the time. 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