Jump to content

Recommended Posts

Posted

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")
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.

Posted

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

Posted

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")
Posted

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.

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...