anks Posted October 1, 2012 Posted October 1, 2012 Hi All, Objective: Need to find a Application named "True Color Finder" running in the system tray of Win XP-32 bit and clicking left click , so that context menu opens up. Script used: expandcollapse popup#Include <GuiToolBar.au3> Opt("WinTitleMatchMode", 2) Global $hSysTray_Handle, $iSysTray_ButtonNumber Global $sToolTipTitle = "True Color Finder" $iSysTray_ButtonNumber = Get_SysTray_Index($sToolTipTitle) If $iSysTray_ButtonNumber = 0 Then MsgBox(16, "Error", "Is True Color Finder Running?") Exit Else Sleep(500) _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSysTray_ButtonNumber, "right") Sleep(2000) ;_GUICtrlToolbar_ClickIndex($hSysTray_Handle,2) Send("{UP}") Send("{UP}") ;Sleep(2000) Send("{ENTER}") ;_GUICtrlToolbar_ClickIndex($hSysTray_Handle,2, "left", True) 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 Problem Statement: The script above works only in few monitors, for other monitors it does not work. Anybody can please provide me help regarding it, i believe that there are some settings changes on the monitor which needs to be done. Can any body guide me regarding the setting changes. Resolution of monitor where the script runs: 1280 x 768. Resolution of monitor where the script does not run: 1920 x 1080. Thank you all of you.
Moderators Melba23 Posted October 1, 2012 Moderators Posted October 1, 2012 anks,I recognise that code! I do not think that the resolution of the screen should affect the code as the code used in _GUICtrlToolbar_ClickButton relies on the API to determine the button position. If you run this version of the script, does the mouse move to the correct place on the screen? If $iSysTray_ButtonNumber = 0 Then MsgBox(16, "Error", "Is True Color Finder Running?") Exit Else $tRect = _GUICtrlToolbar_GetButtonRectEx($hSysTray_Handle, $iSysTray_ButtonNumber) $tPoint = _WinAPI_PointFromRect($tRect) $tPoint = _WinAPI_ClientToScreen($hSysTray_Handle, $tPoint) Local $iX, $iY _WinAPI_GetXYFromPoint($tPoint, $iX, $iY) MouseMove($iX, $iY) EndIfPlease let us know what happens. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
anks Posted October 3, 2012 Author Posted October 3, 2012 @Melba23 I have integrated your code with mine...and it goes as below: expandcollapse popup#Include <GuiToolBar.au3> Opt("WinTitleMatchMode", 2) Global $hSysTray_Handle, $iSysTray_ButtonNumber Global $sToolTipTitle = "True Color Finder" $iSysTray_ButtonNumber = Get_SysTray_Index($sToolTipTitle) If $iSysTray_ButtonNumber = 0 Then MsgBox(16, "Error", "Is True Color Finder Running?") Exit Else $tRect = _GUICtrlToolbar_GetButtonRectEx($hSysTray_Handle, $iSysTray_ButtonNumber) $tPoint = _WinAPI_PointFromRect($tRect) $tPoint = _WinAPI_ClientToScreen($hSysTray_Handle, $tPoint) Local $iX, $iY _WinAPI_GetXYFromPoint($tPoint, $iX, $iY) MouseMove($iX, $iY) 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 But still the same problem persists, directly the IF statement as below runs If $iSysTray_ButtonNumber = 0 Then MsgBox(16, "Error", "Is True Color Finder Running?") Exit and a message prompt is thrown as "Is True Color Finder Running?" Can u please help me how to proceed further
FireFox Posted October 3, 2012 Posted October 3, 2012 (edited) @anksIt means that the trayicon with the tooltip you have specified can not be found. Have you changed the variable to set a tooltip you have?Please apply and tell me if it works.Edit : Changed POST LINK.Br, FireFox. Edited October 3, 2012 by FireFox
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