maloysius Posted January 29, 2020 Share Posted January 29, 2020 Hello AutoIt forums! I was hoping you might be able to help me out with a predicament here. I have spent a few days researching this on the forums and elsewhere, but don't seem to be able to find any specific answers for my needs. It could very well be that I am drastically overlooking something simple. Here goes. I am trying to have AutoIt right click on a tray icon and bring up the menu. Below is the information I get from my taskbar tray area: >>>> Window <<<< Title: Class: Shell_TrayWnd Position: 0, 1040 Size: 1920, 40 Style: 0x96000000 ExStyle: 0x00000088 Handle: 0x00010316 >>>> Control <<<< Class: ToolbarWindow32 Instance: 3 ClassnameNN: ToolbarWindow323 Name: Advanced (Class): [CLASS:ToolbarWindow32; INSTANCE:3] ID: 1504 Text: User Promoted Notification Area Position: 1683, 0 Size: 120, 40 ControlClick Coords: 27, 15 Style: 0x56008B4D ExStyle: 0x00000080 Handle: 0x00010340 >>>> Mouse <<<< Position: 1710, 15 Cursor ID: 0 Color: 0x08090A >>>> StatusBar <<<< >>>> ToolsBar <<<< 1: 2 Ninite Updater - Last update check: 1/28/2020 1:43 PM Updates available: Glary, Notepad++ 2: 3 OneDrive - Oregon POS Up to date 3: 4 Dropbox 89.4.278 Waiting to be linked to a Dropbox account... 4: 1 Network Internet access 5: 0 Speakers: 14% >>>> Visible Text <<<< Start Type here to search Type here to search Task View Running applications Running applications HPSA_TASKBAR System Promoted Notification Area User Promoted Notification Area System Clock, 3:16 PM, 1/28/2020 Action Center >>>> Hidden Text <<<< Type here to search Tray Input Indicator I understand that I can use ControlClick to right click on things, but I can't for the life of me figure out how to get it to right click on a specific icon in the tray area. Is there a way to pass the codes under the "ToolsBar" section to ControlClick...? Also, I would just use the coordinates on the screen, but I need this to work across different computer environments that may not always be the same. This is why I need to work with the specific ID of the tray icon. Anyone have any idea where I can go with this?? I've tried countless different combinations of ControlClick and passing different information through it from the window info tool...but I just can't seem to get it to do a dang thing. Link to comment Share on other sites More sharing options...
Nine Posted January 29, 2020 Share Posted January 29, 2020 I made it work using ImageSearch on Win 7 and Win 10, without transparency. But I suppose it could possible also with UIAutomation... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
maloysius Posted January 29, 2020 Author Share Posted January 29, 2020 Hey Nine! Thanks for the response. I am trying this out but it doesn't seem to see the icon existing in the taskbar after I make the BMP file. Is there maybe something I'm missing here? Link to comment Share on other sites More sharing options...
Nine Posted January 29, 2020 Share Posted January 29, 2020 I got them from the hidden task bar when I left controlClick on it. You need to remove transparency otherwise it won't work. Local $hWnd = WinGetHandle ('[Class:Shell_TrayWnd]') ControlClick($hWnd, '', 1502) “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
maloysius Posted January 29, 2020 Author Share Posted January 29, 2020 When I run that, it opens up the hidden task bar, which is great! At least I know it's clicking over there now. Now if I wanted it to right click on entry 1 in the ToolsBar section of the info, what info do I need to pass to this thing? Link to comment Share on other sites More sharing options...
maloysius Posted January 29, 2020 Author Share Posted January 29, 2020 Oh and I now see that you're using 1502, which is the ID of the hidden taskbar button, so that's why that's happening. So if I were to use 1504, how could I narrow that down to click on entry 1 within 1504? This is the part that confuses me.... Link to comment Share on other sites More sharing options...
maloysius Posted February 3, 2020 Author Share Posted February 3, 2020 Does anyone else have any ideas on this? I can't seem to figure this one out. Link to comment Share on other sites More sharing options...
pixelsearch Posted February 3, 2020 Share Posted February 3, 2020 (edited) Hi maloysius A script found at this link could be helpful, as long as the system tray icon you want to click on got a tooltip (which is common in the notification area). I paste the script below, amended with a few added lines to make it work in case the icon is hidden : expandcollapse popup#Include <GuiToolBar.au3> #NoTrayIcon Global $hSysTray_Handle, $iSystray_ButtonNumber ; Global $sToolTipTitle = "Microsoft Office Outlook" ; <<<<<<<<<<<<<<<< Enter some tooltip text for the icon you want here Global $sToolTipTitle = "Intel(R)" ; <<<<<<<<<<<<<<<< you can enter prefix of your tooltip, no need to enter it all ;~ WinActivate('[Class:Shell_TrayWnd]') ; if taskbar is Autohide $iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle) If $iSystray_ButtonNumber = -1 Then MsgBox(16, "Error", "Icon not found in system tray") Exit Else Sleep(500) _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right") EndIf Exit Func Get_Systray_Index($sToolTipTitle) ; 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 wanted tooltip For $iSystray_ButtonNumber = 0 To $iSystray_ButCount If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sToolTipTitle) <> 0 Then ; MsgBox(0,$iSystray_ButCount,$iSystray_ButtonNumber) ; uncomment if you need info ; 2 lines added in case the icon is hidden (thanks Nine) <======================= Local $hWnd = WinGetHandle ('[Class:Shell_TrayWnd]') ControlClick($hWnd, '', 1502) ControlClick($hSysTray_Handle, "", $iSystray_ButtonNumber, "right") ; <========== Return $iSystray_ButtonNumber ; Found EndIf Next Return -1 ; Not found EndFunc Also, here is an interesting link to choose which items are shown in the notification area, from earlier Windows versions to Windows 10. Good luck Edited February 3, 2020 by pixelsearch maloysius 1 Link to comment Share on other sites More sharing options...
wysocki Posted April 21, 2020 Share Posted April 21, 2020 On 2/3/2020 at 9:12 AM, pixelsearch said: ...amended with a few added lines to make it work in case the icon is hidden... Thanks for pointing this code out, Pixelsearch! Perfect for my need to control the system tray. I just added send("{up"}{enter}") to select from the resulting popup although I'm sure there's a better way. However, your code to make it work when hidden doesn't work for me. It just says "Icon not found..." on my Win7/64 machine. 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