waakaaw Posted April 10, 2009 Share Posted April 10, 2009 Hii I am very new to this tool and aswell this forum. Plz dont mind if any corrections with in this thread I need to close a program which is running, before closing a popup ill ask for "yes" or "no" to exit that program after a few secs(5 secs) i need to open(run) that program again. plz help me how to use autoit for doing so. Thankq Link to comment Share on other sites More sharing options...
Zachlr Posted April 10, 2009 Share Posted April 10, 2009 While 1 ;add this line if you want autoit to start and stop the program every 5 seconds. If MsgBox(4, "Close Program?", "Are you sure you want to exit the program?") = 6 Then ProcessClose("process.exe") Else ;do nothing ContinueLoop ;add this line if you want autoit to start and stop the program every 5 seconds. EndIf Sleep(5000) Run("C:\path\program.exe") Sleep(5000) WEnd ;add this line if you want autoit to start and stop the program every 5 seconds. This will make autoit ask to stop the program every 5 seconds with the marked lines, or every time the autoit program is started, without. I hope this answers your question. Link to comment Share on other sites More sharing options...
waakaaw Posted April 10, 2009 Author Share Posted April 10, 2009 While 1 ;add this line if you want autoit to start and stop the program every 5 seconds. If MsgBox(4, "Close Program?", "Are you sure you want to exit the program?") = 6 Then ProcessClose("process.exe") Else ;do nothing ContinueLoop ;add this line if you want autoit to start and stop the program every 5 seconds. EndIf Sleep(5000) Run("C:\path\program.exe") Sleep(5000) WEnd ;add this line if you want autoit to start and stop the program every 5 seconds. This will make autoit ask to stop the program every 5 seconds with the marked lines, or every time the autoit program is started, without. I hope this answers your question. I want to run it only once, i changed the code can u plz correct it. If MsgBox(4, "program.exe", "Are you sure you want to exit the program?") = 6 Then ProcessClose("program.exe") Else ;do nothing Sleep(5000) Run("C:\path\program.exe") Link to comment Share on other sites More sharing options...
EndFunc Posted April 10, 2009 Share Posted April 10, 2009 (edited) I want to run it only once, i changed the code can u plz correct it. If MsgBox(4, "program.exe", "Are you sure you want to exit the program?") = 6 Then ProcessClose("program.exe") Else ;do nothing Sleep(5000) Run("C:\path\program.exe") You want the whole script to run once?? Try If MsgBox(4, "program.exe", "Are you sure you want to exit the program?") = 6 Then ProcessClose("program.exe") ProcessWaitClose("program.exe") Sleep(5000) Run("C:\path\program.exe") EndIF Edit: Is this what you mean? Edited April 10, 2009 by EndFunc EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
waakaaw Posted April 10, 2009 Author Share Posted April 10, 2009 You want the whole script to run once?? Try If MsgBox(4, "program.exe", "Are you sure you want to exit the program?") = 6 Then ProcessClose("program.exe") ProcessWaitClose("program.exe") Sleep(5000) Run("C:\path\program.exe") EndIF Edit: Is this what you mean? Hi thanq soo much for the quick reply Everything is perfect but 1 problem here, the popup is program based not the 1 we created. Here the popup ill automatically shown up when the program closes manually also. and i dont want to click yes in popup it should clicked automatically. Example I need to close and run yahoomessenger "with popup accepting as yes while closing" If MsgBox(4, "YahooMessenger.exe", "Are you sure you want to exit Yahoo!Messenger?") = 6 Then ProcessClose("YahooMessenger.exe") Exit Else ;do nothing Sleep(5000) Run("C:\Program Files\Yahoo!\Messenger\YahooMessenger.exe") Exit EndIF Link to comment Share on other sites More sharing options...
Zachlr Posted April 10, 2009 Share Posted April 10, 2009 (edited) Ah. I understand. What you are saying is that the other program is what asks if you are sure. In that case, do something like this instead of the message box. WinActivate("Exit Yahoo! Messenger?", "Are you sure you want to exit?") ;activate the popup Send("y"); send the "y" key, this is like clicking yes. Sleep(5000) Run("C:\path\program.exe") Edited April 10, 2009 by Zachlr Link to comment Share on other sites More sharing options...
EndFunc Posted April 10, 2009 Share Posted April 10, 2009 Hi thanq soo much for the quick replyEverything is perfect but 1 problem here, the popup is program based not the 1 we created. Here the popup ill automatically shown up when the program closes manually also. and i dont want to click yes in popup it should clicked automatically.Example I need to close and run yahoomessenger "with popup accepting as yes while closing"If MsgBox(4, "YahooMessenger.exe", "Are you sure you want to exit Yahoo!Messenger?") = 6 ThenProcessClose("YahooMessenger.exe")ExitElse;do nothingSleep(5000)Run("C:\Program Files\Yahoo!\Messenger\YahooMessenger.exe")ExitEndIFTry WinExists() and maybe Send() for the response. EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
waakaaw Posted April 10, 2009 Author Share Posted April 10, 2009 Ah. I understand. What you are saying is that the other program is what asks if you are sure. In that case, do something like this instead of the message box. WinActivate("Exit Yahoo! Messenger?", "Are you sure you want to exit?") ;activate the popup Send("y"); send the "y" key, this is like clicking yes. Sleep(5000) Run("C:\path\program.exe") Thanq so much ... I did it finally with ur help. Cheers WaaKaaW 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