Sign in to follow this  
Followers 0
gottygolly

Guigetmsg(1) error.

5 posts in this topic

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.

Share this post


Link to post
Share on other sites



#3 ·  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.

Share this post


Link to post
Share on other sites

#4 ·  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

Share this post


Link to post
Share on other sites

Well, if you logically check that the array value for the GUI is a hande (IsHwnd), then you can skip the switch block, and not have to worry about the 'dumb' data.


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.

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