Sign in to follow this  
Followers 0
styopa

Using ControlCommand to send toolbar command

9 posts in this topic

First time user of AutoIt here..

I have an application that I need to close all instances of and then restart. After restarting the app I need to click a 'Connect' button that exists in a toolbar. I used the AutoIt v3 Window Info tool to determine the CommandID for the particular button I need. Its Index=1 and CommandID=32771.

Below is my code. It closes all instances and starts up a new instance of the app. But nothing seems to happen when trying to send the toolbar command.

I've tried the commandID 32771 with and without quotations.

Any help would be appreciated.

Opt ("WinTitleMatchMode",2)
$appName = "blah blah"
$appLocation = "C:\BlahBlah.exe"
While WinExists($appName)
WinKill($appName)
WEnd
Run($appLocation)
WinActivate($appName, "")
ControlCommand($appName, "", "[CLASS:ToolbarWindow32; INSTANCE:1]", "SendCommandID", "32771")

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The ControlCommand() syntax you're using is wrong here.

Either of the lines in the 'example' can be used, and the ClassnameNN, or the Advanced Mode, or the ID of the control should be used in place of Button1.

ControlCommand($appName, "", "Button1", "Check") ;
; or
ControlClick($appName, "", "Button1")
Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

I'm not seeing how my syntax is wrong. I did use the Advance Mode for control ID and "SendCommandID" is the command, followed by the specific command id for the toolbar button

Share this post


Link to post
Share on other sites

"SendCommandID" is not a valid command.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Oh, I see it in the online Docs. I am using an older version of AutoIt and that addition is not in the local Help file for that version (3.3.4.0).

Well, good luck then.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

1) try this with your original script

Opt ("WinTitleMatchMode",4)

2) try this instead of your script

Opt ("WinTitleMatchMode",2)
$appName = "blah blah"
$appLocation = "C:BlahBlah.exe"
While WinExists($appName)
WinKill($appName)
WEnd
Run($appLocation)
WinWaitActive($appName, "")
ControlFocus($appName, "", "ToolbarWindow321")
ControlCommand($appName, "", "ToolbarWindow321", "SendCommandID", "32771")

Share this post


Link to post
Share on other sites

I tried both of your suggestions. Neither of them worked. I tested to make sure that the window was activate and the control did in fact have focus. Seems the issue is with the ControlCommand line.

Share this post


Link to post
Share on other sites

Then look at UDFs in the helpfile

#include <GuiToolbar.au3>

_GUICtrlToolbar_ClickButton()

_GUICtrlToolbar_ClickIndex()

_GUICtrlToolbar_CommandToIndex()

...

Maybe it will help you because you can look also at sources of these functions and accomodate them to your needs if needed.

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