Skip to content

Instantly share code, notes, and snippets.

@kissgyorgy
Last active December 21, 2020 17:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kissgyorgy/4510953 to your computer and use it in GitHub Desktop.
Save kissgyorgy/4510953 to your computer and use it in GitHub Desktop.
Autoit: Click a Tray icon in Windows 7
#Include <GuiToolBar.au3>
$hSysTray = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
For $i = 1 To _GUICtrlToolbar_ButtonCount($hSystray)
$sCurrent = _GUICtrlToolbar_GetButtonText($hSystray,$i)
;~ ConsoleWrite($i & ": " & $sCurrent & @CRLF)
If $sCurrent = $sToolTip Then
_GUICtrlToolbar_ClickButton($hSystray, $i, "left")
ExitLoop
EndIf
Next
@adipose
Copy link

adipose commented Aug 12, 2015

No longer works in Windows 10. I have used code like this for years, so I would be interested if someone had solved it for Win10.

@adipose
Copy link

adipose commented Aug 12, 2015

Used Instance:2 to solve the Windows 10 issue.

@chaorace
Copy link

This seems to work on Win10 without fiddling the instance number:

$hSysTray = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Text:User Promoted Notification Area]');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment