Jump to content

Using ControlCommand to send toolbar command


Recommended Posts

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")
Link to post
Share on other sites

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.

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")
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...