Sign in to follow this  
Followers 0
anks

Right click on an app in sys tray + select menu +Read the text

1 post in this topic

Hi All,

I have a task to right click on a certain application in system tray and be able to select (click) an item(from the context menu) and read the text of the item selected.

I am able to select the application from system tray, but not able to read the text.

Please see the snippet of code attached:

#Include <GuiToolBar.au3>


Opt("WinTitleMatchMode", 2)

Global $hSysTray_Handle, $iSysTray_ButtonNumber
Global $sToolTipTitle = "SmartDualMon"

$iSysTray_ButtonNumber = Get_SysTray_Index($sToolTipTitle)

If $iSysTray_ButtonNumber = 0 Then
    MsgBox(16, "Error", "Is SmartDualMon Running?")
    Exit
Else
    Sleep(500)
    _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSysTray_ButtonNumber, "right")
    Sleep(2000)
    ;_GUICtrlToolbar_ClickIndex($hSysTray_Handle,2)
    Send("{UP}")
    Send("{UP}")
    Sleep(1000)
    $ret = _GUICtrlToolbar_GetButtonText($hSysTray_Handle,"#32768")
    msgbox(0,"",$ret)
EndIf


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 - 1
        If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSysTray_ButtonNumber), $sToolTipTitle) = 1 Then ExitLoop
    Next

    If $iSysTray_ButtonNumber = $iSysTray_ButCount Then
        Return 0 ; Not found
    Else
        Return $iSysTray_ButtonNumber ; Found
    EndIf

EndFunc

In the above code using this API "_GUICtrlToolbar_GetButtonText()" i am able to read the text of the other application running in the system tray.

Please advice me regarding it.

Thank U...

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
Sign in to follow this  
Followers 0