gottygolly Posted April 7, 2014 Share Posted April 7, 2014 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. Link to comment Share on other sites More sharing options...
JohnOne Posted April 7, 2014 Share Posted April 7, 2014 it doesn't work right. Is that all you're prepared to tell us? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jdelaney Posted April 7, 2014 Share Posted April 7, 2014 (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 April 7, 2014 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. Link to comment Share on other sites More sharing options...
gottygolly Posted April 7, 2014 Author Share Posted April 7, 2014 (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 April 7, 2014 by gottygolly Link to comment Share on other sites More sharing options...
jdelaney Posted April 7, 2014 Share Posted April 7, 2014 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now