Sign in to follow this  
Followers 0
jdelaney

afx:toolbar manipulation

2 posts in this topic

#1 ·  Posted (edited)

On the most current release of my company's software, we updated our ToolbarWindow32 controls to an afx:Toolbar

I'm able to find the commandids for the buttons I need on the toolbar, but performing the _GUICtrlToolbar_ClickButton on it results in clicking the top left corner of the toolbar.

Anyone familiar with this type of control? Suggestions?

I've tried:

#include <Array.au3>
#include <GuiToolbar.au3>
$hwndWindow = WinGetHandle ( "Our application" )
$hwndToolbar = ControlGetHandle ( $hwndWindow, "", 59392 )
$aPos = ControlGetPos ( $hwndWindow, "", $hwndToolbar ) ; able to find pos of toolbar
$aTools = GetVisibleToolbarButtons ( $hwndWindow, $hwndToolbar )
$iDeleteControlPos = _ArraySearch ( $aTools, "Delete" )
$iDeleteControl = $aTools[$iDeleteControlPos][0]
ConsoleWrite ( $iDeleteControl & @CRLF ) ; Returns 36558
WinActivate ( $hwndWindow )
ControlFocus ( $hwndWindow, "", $hwndToolbar )
_GUICtrlToolbar_ClickButton ( $hwndToolbar, $iDeleteControl, "left", True, 1, 80 )
$atest1 = _GUICtrlToolbar_GetButtonRect ( $hwndToolbar, $iDeleteControl )
$atest2 = _GUICtrlToolbar_GetButtonRectEx ( $hwndToolbar, $iDeleteControl )
$atest3 = _GUICtrlToolbar_GetButtonSize ($hwndToolbar )
;_ArrayDisplay ($atest1,1 ) ; Returns all 0's
;_ArrayDisplay ($atest2,2 ) ; Returns all 0's
;_ArrayDisplay ($atest3,3 ) ; Returns all 0's
ControlFocus ( $hwndWindow, "", $hwndToolbar )
_GUICtrlToolbar_PressButton ( $hwndToolbar, $iDeleteControl )
ControlFocus ( $hwndWindow, "", $hwndToolbar )
$result = ControlCommand ( $hwndWindow, "", $hwndToolbar, "SendCommandID", $iDeleteControl )
ConsoleWrite ( $result & @CRLF ) ; Returns 0

Edit: using relative positions of the control now...only a temporary fix, since there are hundreds of potential buttons that are dynamically present...

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites



phew, ControlCommand works...my issue was i was sending the wrong delete controlcommandid...the function i use to get the id's was not able to filter by isvisible...just need a workaround for that.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

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  
Followers 0