Jump to content
Sign in to follow this  

Unpredictable click on taskbar icons in XP

Recommended Posts

I am automating embedded win XP and choosing an icon from the taskbar based on its tooltip. (third party app) . Recognizing the tooltip is reliable, but more often than not, the click command fails and brings up the taskbar menu instead of the icon's menu. Sometimes it works, no idea what the pattern is. What the best appoach or even a fix?

I have tried:

  • various sleeps
  • click by index and click by command ID
  • unhiding the taskbar ( this seemed to help)
  • True or False parameters in the buttonclick call, tried no optional params too.

code snippet (almost entirely copied from forum):

$hToolbar = ControlGetHandle("[Class:Shell_TrayWnd]", "", "[Class:ToolbarWindow32;Instance:1]")
    If @error Then
        Return SetError(1, 0, 0)

    $iButCount = _GUICtrlToolbar_ButtonCount($hToolbar)
    If $iButCount = 0 Then
        Return SetError(1, 0, 0)

    For $i = 0 To $iButCount - 1
        $cID = _GUICtrlToolbar_IndexToCommand($hToolbar, $i)
        Local $sTrayButText =  _GUICtrlToolbar_GetButtonText($hToolbar, $cID)
        ITHLog("XP_SysTray_Update_Trend: Found Toolbar text: " & $sTrayButText & " cid: " & $cID)
        If StringInStr($sTrayButText, $iTitle) Then
            ; found icon with right tooltip text, now:
            ITHLog("XP_SysTray_Update_Trend: Matched text: " & $sTrayButText & " cid: " & $cID)
            ; without the taskbar un-hide the button click brings up the traskbar menu
            Send("{CTRLDOWN}") ;send a <ctrl>-<esc> to bring up the Taskbar if it's hidden
            _GUICtrlToolbar_ClickButton($hToolbar, $cID, "right", True , 1 ,1 )



Edited by JohnFisher

Share this post

Link to post
Share on other sites

Replying in case it helps anyone else... It seems that our own app causes a problem when it is loaded such that a right click on the third-party icon no longer works - its as if the bitmap hot spot for the icon is off-dimension, or the definition of where it is on screen is off. Autoit ends up hitting the taskbar hot spot, and not the icon itself on a button_click, but only when our app is loaded. The third-party icon in at least one version accepts left or right clicks and a left click seems to work.

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  

  • Create New...