anks Posted March 4, 2011 Share Posted March 4, 2011 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: expandcollapse popup#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... 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