Jump to content

Help with Case Statements


Recommended Posts

I have a main GUI, and i am placing 3 seperate buttons on that gui, each button opens up a separate GUI itself.

$form1 = GUICreate("Test", 830, 600, -1, -1, -1)
$button0 = GUICtrlCreateButton("one", 20, 538, 100, 40, -1)
$button1 = GUICtrlCreateButton("two", 130, 538, 100, 40, -1)
$button2 = GUICtrlCreateButton("three", 240, 538, 100, 40, -1)

GUISetState(@SW_SHOW)

  While 1
      $nMsg = GUIGetMsg()
      select
Case $nmsg = $button0
              msgbox(1,"Test","This is a test 1")
Case $nmsg = $button1
              msgbox(1,"Test","This is a test 2")
Case $nmsg = $button2
              msgbox(1,"Test","This is a test 3")
Case $nmsg = $GUI_EVENT_CLOSE
              guisetstate(@sw_hide,$form1)
endselect
wend

The problem is, if I click on one of the buttons and have the message box pop up and hit okay to continue, I am not able to execute any of the other cases because that while statement is terminated. How do I set it up where it will return back to the beginning of that while loop?

Link to comment
Share on other sites

  • Moderators

I have a main GUI, and i am placing 3 seperate buttons on that gui, each button opens up a separate GUI itself.

$form1 = GUICreate("Test", 830, 600, -1, -1, -1)
$button0 = GUICtrlCreateButton("one", 20, 538, 100, 40, -1)
$button1 = GUICtrlCreateButton("two", 130, 538, 100, 40, -1)
$button2 = GUICtrlCreateButton("three", 240, 538, 100, 40, -1)

GUISetState(@SW_SHOW)

  While 1
      $nMsg = GUIGetMsg()
      select
Case $nmsg = $button0
              msgbox(1,"Test","This is a test 1")
Case $nmsg = $button1
              msgbox(1,"Test","This is a test 2")
Case $nmsg = $button2
              msgbox(1,"Test","This is a test 3")
Case $nmsg = $GUI_EVENT_CLOSE
              guisetstate(@sw_hide,$form1)
endselect
wend

The problem is, if I click on one of the buttons and have the message box pop up and hit okay to continue, I am not able to execute any of the other cases because that while statement is terminated. How do I set it up where it will return back to the beginning of that while loop?

If you tried to show a script that reproduces your issue, with what you've stated so far, the above does not reproduce it. It never exits the loop.

Now, if you are saying that once a message box shows up, that nothing else happens to the script until the message box is terminated, that is correct. With a message box, the script is paused until you carry out an action for that message box.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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...