Jump to content
yian

How to click the icon in system tray at Windows 10

Recommended Posts

yian

Hi,

I case is that a function will automatically start when system boot. But its icon is minimized in the system tray. I need to firstly double-click it to bring the window up. How could I double-click an icon in system tray?

I'm using windows 10. Anybody know how to do it?

Share this post


Link to post
Share on other sites
Subz

Little searching you would have found the following posts:

Put the two together and you would get something like:

#include <Array.au3>
#include <GuiToolBar.au3>

Local $hSysTray_Handle

$sSearchtext='Microsoft Outlook'   ;change to your needs
$iButton=Get_SysTray_IconText($sSearchtext)
_GUICtrlToolbar_ClickButton($hSysTray_Handle, $iButton, "left", False, 2)
MsgBox (64,'Searched Button','Button: '&$iButton&@CRLF&'Instance: '&@extended)

Func Get_SysTray_IconText($sSearch)
    For $i = 1 To 99
        ; Find systray handles
        $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:' & $i & ']')
        If @error Then
            ;MsgBox(16, "Error", "System tray not found")
            ExitLoop
        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")
            ContinueLoop
        EndIf

        Local $aSysTray_ButtonText[$iSysTray_ButCount]

        ; Look for wanted tooltip
        For $iSysTray_ButtonNumber = 0 To $iSysTray_ButCount - 1
            If $sSearch= _GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSysTray_ButtonNumber) Then _
            Return SetError(0, $i, $iSysTray_ButtonNumber)
        Next
    Next
    Return SetError(1, -1, -1)

EndFunc   ;==>Get_SysTray_IconText

 

Share this post


Link to post
Share on other sites
yian

Hi Subz,

Thanks for your help! But it did not work for me. Such as I have OneDrive in the system tray, But your script did not find it.

system_tray.png

I have changed your script for printing all button text found:

        For $iSysTray_ButtonNumber = 0 To $iSysTray_ButCount - 1
            $ButtonText =  _GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSysTray_ButtonNumber)
            ConsoleWrite(@CR & "ButtonText " & $ButtonText)
            If $sSearch= _GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSysTray_ButtonNumber) Then _
            Return SetError(0, $i, $iSysTray_ButtonNumber)
        Next

Then I got the print:

ButtonText

ButtonText AutoIt - test.au3

ButtonText U28E850-4: 12%

ButtonText Network
Internet access

 

 

Share this post


Link to post
Share on other sites
yian

Hi

I found the solution, I should look for the buttons that are hidden.

Local $hSysTray_Handle_Hidden = ControlGetHandle('[Class:NotifyIconOverflowWindow]', '', '[Class:ToolbarWindow32;Instance:1]')

Thanks!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×