MrSheen Posted June 10, 2010 Share Posted June 10, 2010 Hello I've been using the below script to always answer a pop-up box, just cant seem to get it to terminate as soon as program (installrite.exe) closes. Run("C:\Program Files\Epsilon Squared\InstallRite\InstallRite.exe") If $CmdLine[0] = 1 and $CmdLine[1] = '/QUIT' Then WinClose('InstallRite') Else AutoItWinSetTitle('InstallRite') While 1=1 WinWait("InstallRite 2.5c","Are you sure you wan") Send("{ENTER}") WEnd EndIf Tried to include (If ProcessExists),(If ProcessWaitClose),(If WinExists) and Sleep etc but the script does not terminate when the program is closed. Any pointers would be appreciated. Thanks Link to comment Share on other sites More sharing options...
prunesquallor Posted June 10, 2010 Share Posted June 10, 2010 If I understand correctly, once your script enters: While 1=1 WinWait("InstallRite 2.5c","Are you sure you wan") Send("{ENTER}") WEnd the script will never leave the loop. If you only expect the popup once, you could try: WinWaitActive(("InstallRite 2.5c","Are you sure you wan") Send("{ENTER}") Once the script has answered, it can drop through and exit. ATB Prune Link to comment Share on other sites More sharing options...
MrSheen Posted June 10, 2010 Author Share Posted June 10, 2010 (edited) The program asks "do you want to delete?" all the time (so much, they should have had a option to turn that annoying box off), so that script works very well for that purpose but just cant get it to close when the program finishes being used. Thanks for replying Edited June 10, 2010 by MrSheen Link to comment Share on other sites More sharing options...
sahsanu Posted June 10, 2010 Share Posted June 10, 2010 The program asks "do you want to delete?" all the time (so much, they should have had a option to turn that annoying box off), so that script works very well for that purpose but just cant get it to close when the program finishes being used. Thanks for replying Did you try to change 1=1 to ProcessExists("InstallRite.exe")? While ProcessExists("InstallRite.exe") WinWait("InstallRite 2.5c","Are you sure you wan") Send("{ENTER}") WEnd Regards, sahsanu Link to comment Share on other sites More sharing options...
MrSheen Posted June 10, 2010 Author Share Posted June 10, 2010 Replaced 1=1 to ProcessExists("InstallRite.exe") and script was still running after installrite was close, so tried the other one you posted but again script does not close when installrite.exe closes. Link to comment Share on other sites More sharing options...
sahsanu Posted June 10, 2010 Share Posted June 10, 2010 Replaced 1=1 to ProcessExists("InstallRite.exe") and script was still running after installrite was close, so tried the other one you posted but again script does not close when installrite.exe closes.If Process exists then it will wait till window "InstallRite 2.5c" will active, if the process ends when it is waiting your program won't close. Sorry but I'm leaving now so I cannot provide a working script to you, I'll be back later. Link to comment Share on other sites More sharing options...
Juvigy Posted June 10, 2010 Share Posted June 10, 2010 (edited) Run("C:\Program Files\Epsilon Squared\InstallRite\InstallRite.exe") If $CmdLine[0] = 1 and $CmdLine[1] = '/QUIT' Then WinClose('InstallRite') Else AutoItWinSetTitle('InstallRite') While ProcessExists("InstallRite.exe")<>0 WinWait("InstallRite 2.5c","Are you sure you wan") Send("{ENTER}") WEnd EndIf Edited June 10, 2010 by Juvigy Link to comment Share on other sites More sharing options...
sahsanu Posted June 10, 2010 Share Posted June 10, 2010 The program asks "do you want to delete?" all the time (so much, they should have had a option to turn that annoying box off), so that script works very well for that purpose but just cant get it to close when the program finishes being used. Ok, try this "while", this should works: While ProcessExists("InstallRite.exe") If WinExists("InstallRite 2.5c","Are you sure you wan") Then WinActivate("InstallRite 2.5c","Are you sure you wan"); Just to be sure that you get the focus to send the enter Send("{ENTER}") Sleep(100) Else Sleep(100) EndIf WEnd Link to comment Share on other sites More sharing options...
Richard Robertson Posted June 10, 2010 Share Posted June 10, 2010 Run("C:\Program Files\Epsilon Squared\InstallRite\InstallRite.exe") If $CmdLine[0] = 1 and $CmdLine[1] = '/QUIT' Then WinClose('InstallRite') Else AutoItWinSetTitle('InstallRite') While ProcessExists("InstallRite.exe")<>0 If WinWait("InstallRite 2.5c","Are you sure you wan", 1) Then Send("{ENTER}") WEnd EndIf The problem is that the script was stopping on WinWait after the program was gone. Timeouts solve this. Link to comment Share on other sites More sharing options...
norax Posted June 10, 2010 Share Posted June 10, 2010 (edited) Hey man im not sure if everyone else missunderstood you or if i did lol but give this a try and let me know if it helps Run("C:\Program Files\Epsilon Squared\InstallRite\InstallRite.exe") If $CmdLine[0] = 1 and $CmdLine[1] = '/QUIT' Then $pid = ProcessExists("InstallRite.exe") ProcessClose($pid) Else AutoItWinSetTitle('InstallRite') While 1 if WinActive("InstallRite 2.5c","Are you sure you wan") = 1 Then Send("{ENTER}") Sleep(1000) Else $pid = ProcessExists("InstallRite.exe") if $pid = 0 then exit EndIf EndIf WEnd EndIf Edited June 10, 2010 by norax Link to comment Share on other sites More sharing options...
MrSheen Posted June 10, 2010 Author Share Posted June 10, 2010 The last three are great, thank you guys for your assistance. 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