Jump to content

_GUICtrlToolbar_ClickButton


Recommended Posts

Is there some method to get the listbox associated with a toolbar button after right clicking using the

_GUICtrlToolbar_ClickButton function?

The following code works after adding additional x,y values to MouseClick to click the desired

location in the listbox.  I would like to avoid the hard coded values.

Func _TrayNotifyArea()
    Local $hWind = WinGetHandle("[CLASS:Shell_TrayWnd]")
    Local $hButn = ControlGetHandle($hWind, "", 1502)
    Local $hTray = ControlGetHandle($hWind, "", "ToolbarWindow321")
    Local $bCount = _GUICtrlToolbar_ButtonCount($hTray)

    For $i = 1 To $bCount
        If _GUICtrlToolbar_GetButtonText($hTray, $i) == "xearth" Then ExitLoop
    Next
    
    ControlClick($hWind, "", $hButn)
    _GUICtrlToolbar_ClickButton($hTray, $i, "right", True)
    Local $mPos = MouseGetPos()
    MouseClick("left", $mPos[0] + 10, $mPos[1] - 15)
EndFunc

Link to comment
Share on other sites

Realized that I used the a wrong term.  Instead of listbox, it should be context menu.  Anyway,  the menu may popup in a different

location depending on how close to the end of the taskbar.  By assuming, in my case, the menu will popup right of the mouse cursor

may not always work.  I do a ControlClick on the "Hide" button to stretch out the Toolbar to increase my changes of success.

The menu will disappear if I use AutoIt Window finder tool to get info from the menu.  I need some way to select a menu item

within the list.

Link to comment
Share on other sites

Problem solved!!

Replaced:         Local $mPos = MouseGetPos()
                         MouseClick("left", $mPos[0] + 10, $mPos[1] - 15)

 

With:                 Send("{UP}")
                         Sleep(250)
                         Send("{ENTER}")
 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...