styopa Posted December 8, 2011 Share Posted December 8, 2011 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 comment Share on other sites More sharing options...
somdcomputerguy Posted December 8, 2011 Share Posted December 8, 2011 (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 December 8, 2011 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
styopa Posted December 8, 2011 Author Share Posted December 8, 2011 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 Link to comment Share on other sites More sharing options...
somdcomputerguy Posted December 8, 2011 Share Posted December 8, 2011 "SendCommandID" is not a valid command. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
styopa Posted December 8, 2011 Author Share Posted December 8, 2011 It is listed as a command on this site at the very bottomhttp://www.autoitscript.com/autoit3/docs/functions/ControlCommand.htm Link to comment Share on other sites More sharing options...
somdcomputerguy Posted December 8, 2011 Share Posted December 8, 2011 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. Link to comment Share on other sites More sharing options...
Zedna Posted December 8, 2011 Share Posted December 8, 2011 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") Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
styopa Posted December 8, 2011 Author Share Posted December 8, 2011 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. Link to comment Share on other sites More sharing options...
Zedna Posted December 8, 2011 Share Posted December 8, 2011 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. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now