TheRookie Posted September 18, 2006 Share Posted September 18, 2006 I just started using AutoIt the other week. I'm brand new to programming, and I've written a few basic scripts, but I've been reading about better ways to do things. I've done searches on this forum, but I just can't seem to grasp this basic concept, so I'm trying to use ControlSend on the HelloWorld tutorial script. :"> Please tell me what I'm doing wrong. I'm just trying to use ControlSend to click the OK button. MsgBox(0, "Tutorial", "Hello World!") WinWait ("Tutorial") ControlSend ("Tutorial" , "OK" , "2" , "{enter}") I am following the help example of: ControlSend ( "title", "text", controlID, "string" [, flag] ) I don't understand what I'm doing wrong. It looks kind of redundant to have "OK" and "2" there as to what is being targeted, but I'm putting it in to follow the syntax. Then just hitting ENTER seems simple enough. I don't get it. Here is the info from the AutoIt window. I get the info below when I hover the mouse over the OK button. Press CTRL-ALT-F to freeze the display. >>>>>>>>>>>> Window Details <<<<<<<<<<<<< Title: Tutorial Class: #32770 Size: X: 464 Y: 341 W: 104 H: 107 >>>>>>>>>>> Mouse Details <<<<<<<<<<< Screen: X: 532 Y: 422 Cursor ID: 2 >>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<< RGB: Hex: 0xF3F3EF Dec: 15987695 >>>>>>>>>>> Control Under Mouse <<<<<<<<<<< Size: X: 11 Y: 41 W: 75 H: 23 Control ID: 2 ClassNameNN: Button1 Text: OK Style: 0x50030001 ExStyle: 0x00000004 >>>>>>>>>>> Status Bar Text <<<<<<<<<<< >>>>>>>>>>> Visible Window Text <<<<<<<<<<< OK Hello World! >>>>>>>>>>> Hidden Window Text <<<<<<<<<<< My ultimate goal is to be able to write some installation scripts that run hidden. I guess you can use ControlSend to send commands to a hidden window? That way I can run through an installation wizard without it being on the screen. Is that right? Also, ControlSend is supposed to be more accurate from what I have read so far. Also, I have read about people putting safeguards into their scripts, so that if something goes wrong the script will exit. Anyone able to point me in the right direction about how this would work? Link to comment Share on other sites More sharing options...
jpm Posted September 18, 2006 Share Posted September 18, 2006 In Fact you have to understand that the winwait will not be executed before you click on the messagebox. So after you will wait for ever. Use Opt("TrayIconDebug",1) to display where your script is waiting And read and reread the doc Link to comment Share on other sites More sharing options...
BigDod Posted September 18, 2006 Share Posted September 18, 2006 Also if you want to click on the button you need ControlClick instead off ControlSend. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
TheRookie Posted September 18, 2006 Author Share Posted September 18, 2006 Thanks for the Opt("TrayIconDebug",1). That will be useful. Apparently I'm too stupid to see why the script freezes on the HelloWorld button. I reread the tutorial and the descriptions to the commands. There must be some rule about message boxes I don't understand. I've wasted too much time on that message box. I thought working with something simple would help me. Here is my script I want to change from using Send to ControlSend. I have the ControlClick down. I just can't get the ControlSend to work. There is a point during the installation where I must use the keyboard to select a checkbox as it's not a typical windows check-box I can click with the mouse via the script that I know. Therefore I thought that if I could push Shift+Tab to cycle to the box, and then hit Space, I'd be good. The Send command works perfect, I just don't understand the syntax for ControlSend The two lines I can't get working are the first two ControlSend commands. If I can get those down, I'll replace the other Send commands. Here is the AutoIt window with the moust hovering over the checkbox I want to select: Press CTRL-ALT-F to freeze the display. >>>>>>>>>>>> Window Details <<<<<<<<<<<<< Title: Select Components Class: GLBSWizard Size: X: 83 Y: 173 W: 483 H: 364 >>>>>>>>>>> Mouse Details <<<<<<<<<<< Screen: X: 253 Y: 333 Cursor ID: 2 >>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<< RGB: Hex: 0xFFFFFF Dec: 16777215 >>>>>>>>>>> Control Under Mouse <<<<<<<<<<< Size: X: 157 Y: 120 W: 303 H: 107 Control ID: 13 ClassNameNN: ListBox1 Text: Style: 0x50010151 ExStyle: 0x00000204 >>>>>>>>>>> Status Bar Text <<<<<<<<<<< >>>>>>>>>>> Visible Window Text <<<<<<<<<<< &Next > < &Back Cancel 2848254 k 0 k Disk Space Required: Disk Space Remaining: In the options list below, select the checkboxes for the options that you would like to have installed. The disk space fields reflect the requirements of the options you have selected for the Windows 2000 platform. Other platforms may require up to 40 % percent more disk space. NOTE: CruSupport, CruSupport + LDRLite, or LDRLite StandAlone are the three possible selections. >>>>>>>>>>> Hidden Window Text <<<<<<<<<<< Opt("TrayIconDebug",1) Run ("CruxSetup.exe") WinWaitActive ("Welcome" , "Welcome to Cru-X Setup program.") ControlClick ("Welcome" , "Welcome to Cru-X Setup program." , "Button1") WinWaitActive ("Choose Destination Location") ControlClick ("Choose Destination Location" , "Setup will install Cru-X in the following folder" , "Button1") WinWaitActive ("Select Components") AutoItSetOption ( "sendkeydelay" , 2000) ControlSend ("Select Components" , "" , "Control13" , "+{TAB}") ControlSend ("Select Components" , "" , "Control13" , "{SPACE}") sleep (3000) ControlClick ("Select Components" , "Disk Space Required:" , "Button1") WinWaitActive ("Select Program Manager Group") ControlClick ("Select Program Manager Group" , "Program Manager group" , "Button1") WinWaitActive ("Start Installation") ControlClick ("Start Installation" , "ready to install Cru-X." , "Button1") WinWaitActive ("Enter Host Name") Send ("{TAB}") Send ("172.18.115.66") ControlClick ("Enter Host Name" , "Enter the Host Name" , "Button1") WinWaitActive ("Enter Service Name") ControlClick ("Enter Service Name" , "Enter the Service Name" , "Button1") WinWaitActive ("Installation Complete" , "Cru-X has been successfully installed.") ControlClick ("Installation Complete" , "successfully installed." , "Button1") WinWaitActive ("Install") ControlClick ("Install" , "system must be restarted" , "Button3") Link to comment Share on other sites More sharing options...
BigDod Posted September 18, 2006 Share Posted September 18, 2006 Opt("TrayIconDebug",1) Run ("CruxSetup.exe") WinWaitActive ("Welcome" , "Welcome to Cru-X Setup program.") ControlClick ("Welcome" , "Welcome to Cru-X Setup program." , "Button1") WinWaitActive ("Choose Destination Location") ControlClick ("Choose Destination Location" , "Setup will install Cru-X in the following folder" , "Button1") WinWaitActive ("Select Components") AutoItSetOption ( "sendkeydelay" , 2000) ControlSend ("Select Components" , "" , "[s]Control[/s]13" , "+{TAB}") ControlSend ("Select Components" , "" , "[s]Control[/s]13" , "{SPACE}") sleep (3000) ControlClick ("Select Components" , "Disk Space Required:" , "Button1") WinWaitActive ("Select Program Manager Group") ControlClick ("Select Program Manager Group" , "Program Manager group" , "Button1") WinWaitActive ("Start Installation") ControlClick ("Start Installation" , "ready to install Cru-X." , "Button1") WinWaitActive ("Enter Host Name") Send ("{TAB}") Send ("172.18.115.66") ControlClick ("Enter Host Name" , "Enter the Host Name" , "Button1") WinWaitActive ("Enter Service Name") ControlClick ("Enter Service Name" , "Enter the Service Name" , "Button1") WinWaitActive ("Installation Complete" , "Cru-X has been successfully installed.") ControlClick ("Installation Complete" , "successfully installed." , "Button1") WinWaitActive ("Install") ControlClick ("Install" , "system must be restarted" , "Button3") NOte the scored out text. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
TheRookie Posted September 18, 2006 Author Share Posted September 18, 2006 Ahhh I see. Thank you very much! However, it didn't like the controlID for some reason. ControlSend ("Select Components" , "" , "13" , "+{TAB}") I used the ClassNameNN, and it checked the box just fine. Not sure why the Control ID didn't hit the keyboard commands. Control ID: 13 ClassNameNN: ListBox1 I'm like a child learning to talk. Link to comment Share on other sites More sharing options...
jpm Posted September 18, 2006 Share Posted September 18, 2006 Ahhh I see. Thank you very much! However, it didn't like the controlID for some reason. ControlSend ("Select Components" , "" , "13" , "+{TAB}") I used the ClassNameNN, and it checked the box just fine. Not sure why the Control ID didn't hit the keyboard commands. Control ID: 13 ClassNameNN: ListBox1 I'm like a child learning to talk. "13" must be 13 Link to comment Share on other sites More sharing options...
MHz Posted September 19, 2006 Share Posted September 19, 2006 Most of those WinWaitActive() would be best being WinWait() functions as it only gives option for the script to stall if the window does not activate. Control*() functions do not need active windows. This may work better Opt("TrayIconDebug",1) Run ("CruxSetup.exe") WinWait ("Welcome" , "Welcome to Cru-X Setup program.") ControlClick ("Welcome" , "Welcome to Cru-X Setup program." , "Button1") WinWait ("Choose Destination Location") ControlClick ("Choose Destination Location" , "Setup will install Cru-X in the following folder" , "Button1") WinWait ("Select Components") AutoItSetOption ( "sendkeydelay" , 2000) ControlSend ("Select Components" , "" , "ListBox1" , "+{TAB}") ControlSend ("Select Components" , "" , "ListBox1" , "{SPACE}") sleep (3000) ControlClick ("Select Components" , "Disk Space Required:" , "Button1") WinWait ("Select Program Manager Group") ControlClick ("Select Program Manager Group" , "Program Manager group" , "Button1") WinWait ("Start Installation") ControlClick ("Start Installation" , "ready to install Cru-X." , "Button1") WinWait ("Enter Host Name") WinActivate ("Enter Host Name") WinWaitActive ("Enter Host Name") Send ("{TAB}") Send ("172.18.115.66") ControlClick ("Enter Host Name" , "Enter the Host Name" , "Button1") WinWait ("Enter Service Name") ControlClick ("Enter Service Name" , "Enter the Service Name" , "Button1") WinWait ("Installation Complete" , "Cru-X has been successfully installed.") ControlClick ("Installation Complete" , "successfully installed." , "Button1") WinWait ("Install") ControlClick ("Install" , "system must be restarted" , "Button3") Link to comment Share on other sites More sharing options...
TheRookie Posted September 20, 2006 Author Share Posted September 20, 2006 Thank you very much. That is a good idea! This way the application can install even though it's not the active application. I like! 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