Sign in to follow this  
Followers 0
waakaaw

want to close a program and after 5 secs open the same

8 posts in this topic

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

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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")

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by EndFunc

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by Zachlr

Share this post


Link to post
Share on other sites

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

Try WinExists() and maybe Send() for the response.


EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0