atzoref Posted September 19, 2012 Share Posted September 19, 2012 Hi,I want to click on some items of the rightclick menu of external program which exist in the icon trayHow can I do that?Thanks. Link to comment Share on other sites More sharing options...
FireFox Posted September 19, 2012 Share Posted September 19, 2012 Hi,Maybe this: OR some more search...Br, FireFox. Link to comment Share on other sites More sharing options...
atzoref Posted September 19, 2012 Author Share Posted September 19, 2012 I have tried this: CreatoX, This code will right click on an icon containing a given text - I have found that Send("{UP}/{DOWN}{ENTER}") works well from then on if you add a Sleep(100) between multiple commands to allow them time to have effect. expandcollapse popup#Include <GuiToolBar.au3> Global $hSysTray_Handle, $iSystray_ButtonNumber Global $sToolTipTitle = "" ; <<<<<<<<<<<<<<<< Enter some tooltip text for the icon you want here $iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle) If $iSystray_ButtonNumber = 0 Then MsgBox(16, "Error", "Icon not found in system tray") Exit Else Sleep(500) _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right") EndIf Exit ;............ 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 You may find that there are accelerator keys within the menu and just Send("a") will work, although I see no sign of them in that image - worth a try though! M23 But It is doesn't works. I'm writing in $sToolTipTitle = "" the title of the tray icon. but it is always shows me the message "Icon not found in system tray". (I am using X64 Win7) Also what I need to do after it recognized it? There is another way instead of UP/DOWN on the rightclick menu? maybe click on item by its string? Link to comment Share on other sites More sharing options...
FireFox Posted September 19, 2012 Share Posted September 19, 2012 The script was made for a particular demand, so here you go : expandcollapse popup#include <GuiToolBar.au3> Global $hSysTray_Handle, $iSystray_ButtonNumber Global $sToolTipTitle = "" $iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle) If $iSystray_ButtonNumber = -1 Then MsgBox(16, "Error", "Icon not found in system tray") Exit Else _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right") EndIf Exit 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 ConsoleWrite(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber) & @CRLF) If _GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber) = $sToolTipTitle Then ConsoleWrite($iSystray_ButtonNumber & @CRLF) Return $iSystray_ButtonNumber ; Found EndIf Next Return -1 ; Not found EndFunc ;==>Get_Systray_Index I suggest you to copy what you have in the console because in some cases there are special chars. Sorry for waiting i'm on a public WiFi which sucks... Br, FireFox. Link to comment Share on other sites More sharing options...
FireFox Posted September 19, 2012 Share Posted September 19, 2012 Also what I need to do after it recognized it? If you want to click on the bottom item then you just have to send the enter key, if you want to 2nd item from the bottom then : Send("{UP 1}{ENTER}") Br, FireFox. 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