raviray Posted August 24, 2011 Posted August 24, 2011 I am creating simple auto it script in which I am stuck on first screen itslef Auto-it script triggers setup.exe but after that its not going further. For the same dialogue box clicking enter manually works great but I have used send({Enter}) command which is not working. I tried with controlsend & using sleep as well but no success. please help!! script code ;starts from here Run("Setup.exe") WinWaitActive("UPS WorldShip", "&Language Selection") sleep(1000) Send ("ENTER")
jvanegmond Posted August 24, 2011 Posted August 24, 2011 It's getting stuck on WinWaitActive because it doesn't find a window with matching title and text. github.com/jvanegmond
Mikeman27294 Posted August 24, 2011 Posted August 24, 2011 (edited) Firstly, use a code snippet. All you need to do is insert (Should be a square bracket) {code] Code goes here Second, you should use send({enter}). If that doesnt work, then it is something else. Thirdly, is the window name correct? Edited August 24, 2011 by Mikeman27294
raviray Posted August 25, 2011 Author Posted August 25, 2011 It's getting stuck on WinWaitActive because it doesn't find a window with matching title and text.I used autoit Window Info tool to fetch Title & text.I know I am giving correct title but its not able to recognize window.I tried with this script as well but didnt make difference.Run( "Setup.exe" )WinWaitActive( "UPS WorldShip" )Send ( "ENTER" )Could you please suggest whatelse I can try..Using ControlClick will help or not?I am new to autoit..trying different ways by checking sample scripts.Thanks for your help.
smashly Posted August 25, 2011 Posted August 25, 2011 Hi, Typing 3 lines and hoping for the best isn't working. Obvious suggestion would be to add some debug/error checking each step of your code so you can work out where it fails. eg;$iPid = Run( "Setup.exe" ) ConsoleWrite("Run @error: " & @error & @LF) If Not $iPid Then Exit $hWindow = WinWait("UPS WorldShip", "", 5) ConsoleWrite("WinWait found window: " & ($hWindow <> 0) & @LF) If Not $hWindow Then Exit $hWindow = WinActivate($hWindow) ConsoleWrite("WinActivate activated window: " & ($hWindow <> 0) & @LF) If Not $hWindow Then Exit Send("{ENTER}") Cheers
raviray Posted August 25, 2011 Author Posted August 25, 2011 autoit]$iPid = Run( "Setup.exe" ) This is the only line which is being executed and after that script exits on next dialogue. I have enclosed dialogue box in which I want to select English & manually clicking on enter takes to the next screen. Any suggestions ??
monoscout999 Posted August 25, 2011 Posted August 25, 2011 (edited) post the data from the autoit window info tool, the summary tab only selectin the button that you want to click also. something like this >>>> Window <<<< Title: G:\Agustin\autoit\Prueba1.au3 - SciTE [4 of 4] Class: SciTEWindow Position: -8, -8 Size: 1696, 1026 Style: 0x17CF0000 ExStyle: 0x00000110 Handle: 0x00000000000802DC >>>> Control <<<< Class: Scintilla Instance: 1 ClassnameNN: Scintilla1 Name: Advanced (Class): [CLASS:Scintilla; INSTANCE:1] ID: 350 Text: S Position: 2, 50 Size: 1676, 788 ControlClick Coords: 491, 662 Style: 0x56000000 ExStyle: 0x00000000 Handle: 0x00000000000D02DE >>>> Mouse <<<< Position: 493, 754 Cursor ID: 0 Color: 0xF0F4F9 >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< Source EDITED Edited August 25, 2011 by monoscout999
raviray Posted August 25, 2011 Author Posted August 25, 2011 This is summary while selecting English using finder tool. in Autoit help I could see this command as well ControlClick ( "title", "text", controlID [, button [, clicks [, x [, y ]]]] ) but I am not sure what to put in clicks here. Summary is given below - >>>> >>>> Window <<<< Title: UPS WorldShip Class: WindowsForms10.Window.8.app.0.33c0d9d Position: 176, 117 Size: 800, 600 Style: 0x16010000 ExStyle: 0x000D0000 Handle: 0x000E00B4 >>>> Control <<<< Class: WindowsForms10.STATIC.app.0.33c0d9d Instance: 13 ClassnameNN: WindowsForms10.STATIC.app.0.33c0d9d13 Name: langLink1 Advanced (Class): [NAME:langLink1] ID: 131316 Text: English Position: 35, 140 Size: 266, 39 ControlClick Coords: 132, 23 Style: 0x5601000D ExStyle: 0x00000000 Handle: 0x000200F4 >>>> Mouse <<<< Position: 343, 280 Cursor ID: 0 Color: 0x5E6168 <<<<
shornw Posted August 25, 2011 Posted August 25, 2011 It may not help, but I would start with: Firstly, reduce the Window Title to as few characters as possible, while still ensuring it's unique then, to test, follow with a messagebox to ensure that the window is found (remove or comment out the MsgBox when it works) ie WinWait("UPS") If WinExist("UPS") Then MsgBox(0, "Window Exists", "Window found") WinActivate("UPS) Send("{ENTER}") EndIf I have had similar issues in the past, and generally it turned out that I was the error ;-) [font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]
raviray Posted August 25, 2011 Author Posted August 25, 2011 Thanks Shornw - I will try it and let you know.
shornw Posted August 25, 2011 Posted August 25, 2011 **Missing quote in WinActivate in code snippet. Should be WinWait("UPS") If WinExist("UPS") Then MsgBox(0, "Window Exists", "Window found") WinActivate("UPS") Send("{ENTER}") EndIf Your original code WinWaitActive("UPS WorldShip", "&Language Selection"), would wait for the window to be active , which may be the problem. If the window opens but isn't the active window the script will just wait. WinWait("UPS") will wait for the window to appear, then WinActivate("UPS") shifts focus to it before sending the Enter command (You should check that 'Enter' is activated on the window as you may have to send Tab commands ( Send("[TAB}") ) to make it work. Send commands require quotation then curly brackets { } for keys other than alphabet. [font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]
raviray Posted August 25, 2011 Author Posted August 25, 2011 Thank you Shornw for explaining it so well. I corrected that missing " in snippet while testing but while executing script it gave error Unknown function name. For line 3 Run( "Setup.exe" ) WinWait("UPS") If WinExist("UPS") Then MsgBox(0, "Window Exists", "Window found") WinActivate("UPS") Send("{ENTER}") EndIf I have checked the TAB part,English is first/Default option here so by sending ENTER command manually, it goes to the next screen. Thanks again.
shornw Posted August 25, 2011 Posted August 25, 2011 Sorry, all typos today. WinExist should be WinExists - corrected below. I ran this and it worked OK so try now Run( "Setup.exe" ) WinWait("UPS") If WinExists("UPS") Then MsgBox(0, "Window Exists", "Window found") WinActivate("UPS") Send("{ENTER}") EndIf [font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]
raviray Posted August 26, 2011 Author Posted August 26, 2011 (edited) Sorry, all typos today.WinExist should be WinExists - corrected below.Thanks shornw - I am so dumb couldnt identify myself that its not showing correctly in editor.I am checking now and will revert.Thanks again. Edited August 26, 2011 by raviray
raviray Posted August 26, 2011 Author Posted August 26, 2011 (edited) Sorry, all typos today.WinExist should be WinExists - corrected below.Awesome Shornw - Its working!!!Thank you all of you for helping me out in this.Now I will check next dialogues and I know I may stuck again n come back to you as there is one screen in which first radio button needs to be selected and then next button.And also if we want to change default directory then what command syntax we need to use.Its all related to this app so I am not sure wethere i will have to submit new query for that.Thanks again!!Have a pleasant day ahead. Edited August 26, 2011 by raviray
raviray Posted August 26, 2011 Author Posted August 26, 2011 Awesome Shornw - Its working!!!Thank you all of you for helping me out in this.Ok..so here I come again.As I thought I am stuck at Installation type selection screen where I need to choose Radio Button and click on next.In next screen - Setup preferenceNeed to change destination directorySelect Country from drop downUncheck desktop shortcutCould you please suggest on which functions need to use here.P.S. - Do we have function to select an option from drop down list.Please suggest.
shornw Posted August 26, 2011 Posted August 26, 2011 Use the Send("{TAB}") command to move from one item to the next. Check the helpfiles as you can send multiple items by using a number like - Send("{TAB 2}") You can move to the drop down menu and then use Send("{DOWN}") or Send("{DOWN 3}") to select an item To select the directory, TAB to it and then use Send("C:\TargetDirectory") Send is your friend [font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]
raviray Posted August 26, 2011 Author Posted August 26, 2011 (edited) Send is your friend I will keep it in mind In any of the above mentioned requirement do i not need ContolClick?I was trying with controlclik..was not working..now I will try with Send.I will revert in case I have any questions.Thanks again. Edited August 26, 2011 by raviray
shornw Posted August 26, 2011 Posted August 26, 2011 I like to keep things as simple as possible, also I use keyboard shortcuts a lot in everyday use as I find it is often quicker than using a mouse. I have never used ControlClick, but that's just me. I have used a combination of Send with "{TAB]" "{SPACE}" and "{ENTER}" for all sorts of stuff very successfully. Experiment and see how you get on [font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]
raviray Posted August 26, 2011 Author Posted August 26, 2011 (edited) I like to keep things as simple as possible, also I use keyboard shortcuts a lot in everyday use as I find it is often quicker than using a mouse. I have never used ControlClick, but that's just me. I have used a combination of Send with "{TAB]" "{SPACE}" and "{ENTER}" for all sorts of stuff very successfully. Experiment and see how you get on I did as you told me to do..and here I am..completed the script..roughly but yes its installing fine. Here comes the code- expandcollapse popupRun( "Setup.exe" ) WinWait("UPS WorldShip") If WinExists("UPS WorldShip") Then ;MsgBox(0, "Window Exists", "Window found") WinActivate("UPS WorldShip") Send("{ENTER}") EndIf If WinExists("UPS WorldShip") Then ;MsgBox(0, "Window Exists1", "Window found") WinActivate("UPS WorldShip") Send("{ENTER}") EndIf $hWindow = WinWait("UPS WorldShip", "", 5) If Not $hWindow Then Exit MsgBox(0, "Window Exists2", "Window found") $hWindow = WinActivate($hWindow) Send("{ENTER}") ConsoleWrite("WinActivate activated window: " & ($hWindow <> 0) & @LF) If Not $hWindow Then Exit $hWindow = WinWait("UPS WorldShip", "Please select desired installation type", 5) If Not $hWindow Then Exit MsgBox(0, "Window Exists3", "Window found") $hWindow = WinActivate($hWindow) Send("{TAB}") Send("{SPACE}") Send("!n") If Not $hWindow Then Exit $hWindow = WinWait("UPS WorldShip", "Setup Preferences", 5) If Not $hWindow Then Exit MsgBox(0, "Window Exists4", "Window found") $hWindow = WinActivate($hWindow) Send("{TAB}") Send("C:\Program Files\UPS\WSTD") Send("{TAB 2}") Send("{SPACE}") Send("{DOWN 4}") Send("{TAB}") Send("{-}") Send("!n") Send("!n") If Not $hWindow Then Exit WinWait("UPS WorldShip") WinActivate("UPS WorldShip") Send("{ENTER}") My last two queries : Installation takes some 5-7 minutes and in the end Reboot prompt comes which will do fine with Send("{ENTER}") key but I am not sure on how to track the time when this window will prompt. Also in the above mentioned script if I remove msg box for 3 & 4 dialogue its not working so how can I fix that? Thanks alot team. Edited August 26, 2011 by raviray
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