CreatoX, Would sir like fries with that? You can thank rover for this - all I have done is play around with his code to get a "simple" function to do what you want: #include <WindowsConstants.au3>
#include <GUIToolbar.au3>
#include <WinAPI.au3>
#Include <GuiMenu.au3>
Opt("WinTitleMatchMode", 2)
Global $hSysTray_Handle, $iSystray_ButtonNumber
Global $sToolTipTitle = "" ; Add the text of your tray icon here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle)
If $iSystray_ButtonNumber = 0 Then
MsgBox(16, "Error", "Is the App running?")
Exit
Else
Sleep(250)
_GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right")
Sleep(250)
Send("{UP}") ; Move your cursor around on the menu here <<<<<<<<<<<<<<<<<<<<<<<<<<<
ConsoleWrite(GetPopUpSelText() & @CRLF) ; This will read the currently selected item <<<<<<<<<<<<<<<<<<<<<<<<<<<<
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) <> 0 Then ExitLoop
Next
If $iSystray_ButtonNumber = $iSystray_ButCount Then
Return 0 ; Not found
Else
Return $iSystray_ButtonNumber ; Found
EndIf
EndFunc
Func GetPopUpSelText()
Local $aPopUp_List = _WinAPI_EnumWindowsPopup()
Local $hWnd = $aPopUp_List[1][0]
Local $sClass = $aPopUp_List[1][1]
If $sClass = "#32768" Then ; This is a "standard" Windows API popup menu
$hMenu = _SendMessage($hWnd, $MN_GETHMENU, 0, 0)
If _GUICtrlMenu_IsMenu($hMenu) Then
$iCount = _GUICtrlMenu_GetItemCount($hMenu)
For $j = 0 To $iCount - 1
If _GUICtrlMenu_GetItemHighlighted($hMenu, $j) Then
Return _GUICtrlMenu_GetItemText($hMenu, $j)
EndIf
Next
EndIf
EndIf
Return ""
EndFuncThis code only works on "standard" Windows API popup menus - one of the apps in my tray does not respond to this code as it uses owner-drawn elements which cannot be read. I hope your app is one of the well-behaved ones. M23