BartDog Posted July 18, 2013 Share Posted July 18, 2013 Greetings all! Obviously I am new to this forum and even more obviously I am new to AutoIT. But I am enjoying it and getting a lot of useful things out of it. I have been using these forums since I started messing around with AutoIT for hints and things to research. But I am now stuck on this one issue at the moment and was hoping someone could point me in the right direction or just point out what I am doing wrong with my scripts. This part of my script is pretty simple. All I am having it do is launch a program and launch an update when the update window shows. All that works fine but every once in a while it gets an error right after launching the program. At that point I am wanting it to clear the error (enter or click OK) and relaunch the program and start the update. I have tried the following scripts but none seem to work. Any assistance would be appreciated. Run('C:CMProgram.exe') If WinActivate("Error", "") Then Send("{ENTER}") Sleep(2000) Run('C:CMProgram.exe') EndIf _WinWaitActivate("Update Application", "") Send("{ENTER}") ;===================================================== Func CMerror() If _WinWaitActivate("Error", "&OK") Then MouseClick("left", 266, 11, 1) MouseClick("left", 286, 98, 1) Sleep(2000) Run('C:CMProgram.exe') EndIf EndFunc ;==>CMerror AdlibRegister("CMerror") Run('C:CMProgram.exe') _WinWaitActivate("Update Application", "") Send("{ENTER}") AdlibUnRegister("CMerror") ;================================================== Run('C:CMProgram.exe') _WinWaitActivate("Error", "", 15) Send("{ENTER}") Sleep(2000) Run('C:CMProgram.exe') _WinWaitActivate("Update Application", "") Send("{ENTER}") Link to comment Share on other sites More sharing options...
0xdefea7 Posted July 18, 2013 Share Posted July 18, 2013 (edited) Try using the WinExists function to check for the error window. You should be able to just send enter after that. You may possibly have to TAB, then enter. Also, you may find the info tool useful (Ctrl + F6 when using SciTE). http://www.autoitscript.com/autoit3/docs/intro/au3spy.htm Edited July 18, 2013 by 0xdefea7 BartDog 1 Link to comment Share on other sites More sharing options...
BartDog Posted July 18, 2013 Author Share Posted July 18, 2013 Thanks for the suggestion. I have tried winexists (with the script below) and it did not work either. I did put in the extra info from AU3Info which just the text "&OK" which I believe is not a requirement. Run('C:CMProgram.exe') Sleep(5000) If WinExists("Error", "&OK") Then Send("{ENTER}") Sleep(2000) Run('C:CMProgram.exe') EndIf _WinWaitActivate("Update Application", "") Send("{ENTER}") Any other ideas too look into would be appriciated. Link to comment Share on other sites More sharing options...
Solution 0xdefea7 Posted July 18, 2013 Solution Share Posted July 18, 2013 What about getting the Class info for the window and using it as the first argument in your WinExists: WinExists("[Title:Error; Class:Program]", "") Check this reference out for more ways to match the window title. Once you have that working, the rest will be easy. Using the au3info tool and this reference, you should be able to solve it http://www.autoitscript.com/autoit3/docs/intro/windowsadvanced.htm BartDog 1 Link to comment Share on other sites More sharing options...
BartDog Posted July 19, 2013 Author Share Posted July 19, 2013 I shall try out some of the Advanced Window Descriptions asap. Though it may be a few more days before I can. Thanks for the info. Link to comment Share on other sites More sharing options...
BartDog Posted July 30, 2013 Author Share Posted July 30, 2013 I finally got some machines up to do some testing and I believe I have finally got this working. Thanks you very much for your assistance. Link to comment Share on other sites More sharing options...
0xdefea7 Posted July 30, 2013 Share Posted July 30, 2013 Please mark the topic as solved then, it is also nice to post your solution so that others can learn from it, not just you Link to comment Share on other sites More sharing options...
BartDog Posted July 31, 2013 Author Share Posted July 31, 2013 You are so right. The solution was some of your suggestions and a few mistake corrections (Sequence error on my part). Ended up with the following: If WinExists("Error", "&OK") Then WinActivate("Error", "&OK") Send("{Enter}") Sleep(2000) Run('C:CMProgram.exe') EndIf Thanks Again. 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