Jump to content

Re-run MsgBox when a user clicks No


Go to solution Solved by Jos,

Recommended Posts

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!

Link to comment
Share on other sites

  • Developers
  • Solution

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...