Jump to content

Recommended Posts

Posted

This always worked and it still works in older scripts I have but if I try to type a new one it doesn't work right.

Here's the code:

Global $gui2, $button2
$gui = GUICreate("Gui 1",200,200,-1,-1)
$button1 = GUICtrlCreateButton("Gui 1 Button",0,0,100,25)
GUISetState()
while 1
   $msg = GUIGetMsg(1)
   Switch $msg[1]
   Case $gui
      Switch $msg[0]
      ;Case -3
         ;Exit
      Case $button1
         gui2()
      EndSwitch
   Case $gui2
      Switch $msg[0]
      ;Case -3
         ;Exit
      Case $button2
         MsgBox(0,"Gui2","From Gui2")
      EndSwitch
   EndSwitch
WEnd

Func gui2()
   $gui2 = GUICreate("Gui 2",200,200,-1,-1)
   $button2 = GUICtrlCreateButton("Gui 2 Button",0,0,100,25)
   GUISetState()
   EndFunc

Thanks.

Posted (edited)

If no message is returned, then the $msg[1] is 0...which matches the switch case for gui2, which is empty/null when not created.

You can add fake variable values like this to get around that.

Global $gui2=99, $button2=99
$gui = GUICreate("Gui 1",200,200,-1,-1)
$button1 = GUICtrlCreateButton("Gui 1 Button",0,0,100,25)
GUISetState()
while 1
   $msg = GUIGetMsg(1)
   Switch $msg[1]

   Case $gui
      Switch $msg[0]
      ;Case -3
         ;Exit
      Case $button1
         gui2()
      EndSwitch
   Case $gui2
      Switch $msg[0]
      ;Case -3
         ;Exit
      Case $button2
         MsgBox(0,"Gui2","From Gui2")
      EndSwitch
   EndSwitch
WEnd

Func gui2()
   $gui2 = GUICreate("Gui 2",200,200,-1,-1)
   $button2 = GUICtrlCreateButton("Gui 2 Button",0,0,100,25)
   GUISetState()
EndFunc

That will fix the messagebox from popping up repeately.  Other than that, there are still many issues with your code.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Posted (edited)

Dumb that you have to set them =99 or any number though.

I didn't have to set them =99 in the script below and it runs perfectly fine.

(Download because it's 1500 lines of code and it sucks going through that on a phone.)

Game.au3

Edited by gottygolly

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
  • Recently Browsing   0 members

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