Jump to content
Sign in to follow this  
billrr02

Re-run MsgBox when a user clicks No

Recommended Posts

billrr02

How do I force this MsgBox to pop up again after a specified amount of time (let's say 5 minutes) when a user clicks "No"? Currently it simply exits the program, but I want it to be annoying and pop up until the user chooses to restart, :shifty:.
 

When a user clicks "Yes", it will restart the computer.

 

$answer = MsgBox(69684, "Title" , "Test Message." & @CR & "" & @CR & "Would you like to restart now?")
 

If $answer=7 Then
      Exit
EndIf

 

Shutdown(6)

Any help would be appreciated.

Thank you!

Share this post


Link to post
Share on other sites
Jos

mmm that shouldn't be too difficult. Here's something to play with:

While 1
    $answer = MsgBox(69684, "Title", "Test Message." & @CR & "" & @CR & "Would you like to restart now?")
    If $answer = 6 Then Shutdown(6)
    Sleep(1000 * 60 * 5)
WEnd

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
JCEF

Good night!

I think this is what you want ....

Global $answer

FuncMsg()

Func FuncMsg()
    $answer = MsgBox(69684, "Title", "Test Message." & @CR & "" & @CR & "Would you like to restart now?")
    If $answer = 7 Then
        Sleep(30000) ; Time to wait
        FuncMsg()
    Else
        ;MsgBox(0,"", "Reboot")
        Shutdown(6)
    EndIf
EndFunc   ;==>FuncMsg

Hope this helps.

Share this post


Link to post
Share on other sites
Jos

Good night!

I think this is what you want ....

Global $answer

FuncMsg()

Func FuncMsg()
    $answer = MsgBox(69684, "Title", "Test Message." & @CR & "" & @CR & "Would you like to restart now?")
    If $answer = 7 Then
        Sleep(30000) ; Time to wait
        FuncMsg()
    Else
        ;MsgBox(0,"", "Reboot")
        Shutdown(6)
    EndIf
EndFunc   ;==>FuncMsg

Hope this helps.

Don't think this is what he wants as this example reruns FuncMsg() without ending it and will ultimately get a StackOverflow.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
billrr02

mmm that shouldn't be too difficult. Here's something to play with:

While 1
    $answer = MsgBox(69684, "Title", "Test Message." & @CR & "" & @CR & "Would you like to restart now?")
    If $answer = 6 Then Shutdown(6)
    Sleep(1000 * 60 * 5)
WEnd

Jos

This worked perfectly. Thanks :thumbsup:

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  

×