evilertoaster Posted June 27, 2006 Posted June 27, 2006 Hey, i posted this same question a while back but it was not answered and now I'm needing a solution to it agian... Here's the sample code- #include <GUIConstants.au3> opt ("Guioneventmode",1) ;make GUI1 $GUI1=GUICreate("GUI1") $button1=GUICtrlCreateButton("button1", 50, 50) GUICtrlSetOnEvent($button1, "action1") ;Make GUI2 $GUI2 = GUICreate("GUI2") $button2=GUICtrlCreateButton("button2", 50, 50) GUICtrlSetOnEvent($button2,"action2") ;Show GUI1 GUIsetstate(@SW_SHOW,$GUI1) ;Wait around While 1 sleep (1000) WEnd ;Button1 is pressed... func action1 () GUISetState(@SW_SHOW,$GUI2) ;show GUI2 then wait around while 1 sleep (1000) WEnd endfunc ;when button2 is pressed this function IS NOT CALLED func action2 () MsgBox(0,"OK","You pressed button2") endfunc Basically it won't call my action2() function when I press a button... any ideas?
kcd-clan Posted June 27, 2006 Posted June 27, 2006 (edited) Case $msg = $Button1 action1() Case $msg = $Button2 action2() You can use this way to do it. Edited June 27, 2006 by kcd-clan Visit mEMy programs made.Iul - IulG-V Console - G-V Console_RandomLetter - _RandomLetter()Saftey Kill - Saftey Killcolorzone() = colorzone()
Skruge Posted June 27, 2006 Posted June 27, 2006 Hey, i posted this same question a while back but it was not answered and now I'm needing a solution to it agian...Why not revive that thread? Anyway, due to your endless loop, action1 never ends. Ditch the loop and action2 will launch properly. Not sure if you plan to add actual code to action1, but you could accomplish the same thing in your main loop.expandcollapse popup#include <GUIConstants.au3> opt ("Guioneventmode",1) opt ("TrayIconDebug",1) local $bGUI2Active = 0 ;make GUI1 $GUI1=GUICreate("GUI1") $button1=GUICtrlCreateButton("button1", 50, 50) GUICtrlSetOnEvent($button1, "action1") ;Make GUI2 $GUI2 = GUICreate("GUI2") $button2=GUICtrlCreateButton("button2", 50, 50) GUICtrlSetOnEvent($button2,"action2") ;Show GUI1 GUIsetstate(@SW_SHOW,$GUI1) ;Wait around While 1 sleep (1000) if $bGUI2Active Then ; Insert the code you were going to put in action1() ;~ while 1 ;~ sleep (1000) ;~ WEnd EndIf WEnd ;Button1 is pressed... func action1 () ;show GUI2 then don't wait around GUISetState(@SW_SHOW,$GUI2) $bGUI2Active = 1 endfunc ;when button2 is pressed this function IS NOT CALLED func action2 () MsgBox(0,"OK","You pressed button2") endfunc [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]
evilertoaster Posted June 27, 2006 Author Posted June 27, 2006 (edited) Case $msg = $Button1action1Case $msg = $Button2action2I think not?opt ("Guioneventmode",1) Different GUI mode.... Edited June 27, 2006 by evilertoaster
kcd-clan Posted June 27, 2006 Posted June 27, 2006 expandcollapse popup#include <GUIConstants.au3> ;make GUI1 $GUI1=GUICreate("GUI1") $button1=GUICtrlCreateButton("button1", 50, 50) ;Make GUI2 $GUI2 = GUICreate("GUI2") $button2=GUICtrlCreateButton("button2", 50, 50) ;Show GUI1 GUIsetstate(@SW_SHOW,$GUI1) ;Wait around While 1 $msg = GuiGetMsg() Select Case $msg = $Button1 action1() Case $msg = $Button2 action2() Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Exit ;Button1 is pressed... func action1 () GUISetState(@SW_SHOW,$GUI2) ;show GUI2 then wait around endfunc ;when button2 is pressed this function IS NOT CALLED func action2 () MsgBox(0,"OK","You pressed button2") endfunc Visit mEMy programs made.Iul - IulG-V Console - G-V Console_RandomLetter - _RandomLetter()Saftey Kill - Saftey Killcolorzone() = colorzone()
kcd-clan Posted June 27, 2006 Posted June 27, 2006 expandcollapse popup$gui=1 #include <GUIConstants.au3> ;make GUI1 $GUI1=GUICreate("GUI1") $button1=GUICtrlCreateButton("button1", 50, 50) ;Make GUI2 $GUI2 = GUICreate("GUI2") $button2=GUICtrlCreateButton("button2", 50, 50) ;Show GUI1 GUIsetstate(@SW_SHOW,$GUI1) ;Wait around While 1 $msg = GuiGetMsg() Select Case $msg = $Button1 action1() Case $msg = $Button2 action2() Case $msg = $GUI_EVENT_CLOSE If $gui=1 Then ExitLoop EndIf If $gui=2 Then GUIsetstate(@SW_HIDE,$GUI2) $gui=1 EndIf Case Else ;;;;;;; EndSelect WEnd Exit ;Button1 is pressed... func action1 () $gui=2 GUISetState(@SW_SHOW,$GUI2) ;show GUI2 then wait around endfunc ;when button2 is pressed this function IS NOT CALLED func action2 () MsgBox(0,"OK","You pressed button2") endfunc a better one. Visit mEMy programs made.Iul - IulG-V Console - G-V Console_RandomLetter - _RandomLetter()Saftey Kill - Saftey Killcolorzone() = colorzone()
evilertoaster Posted June 27, 2006 Author Posted June 27, 2006 (edited) Why not revive that thread? Anyway, due to your endless loop, action1 never ends. Ditch the loop and action2 will launch properly. Not sure if you plan to add actual code to action1, but you could accomplish the same thing in your main loop.expandcollapse popup#include <GUIConstants.au3> opt ("Guioneventmode",1) opt ("TrayIconDebug",1) local $bGUI2Active = 0 ;make GUI1 $GUI1=GUICreate("GUI1") $button1=GUICtrlCreateButton("button1", 50, 50) GUICtrlSetOnEvent($button1, "action1") ;Make GUI2 $GUI2 = GUICreate("GUI2") $button2=GUICtrlCreateButton("button2", 50, 50) GUICtrlSetOnEvent($button2,"action2") ;Show GUI1 GUIsetstate(@SW_SHOW,$GUI1) ;Wait around While 1 sleep (1000) if $bGUI2Active Then ; Insert the code you were going to put in action1() ;~ while 1 ;~ sleep (1000) ;~ WEnd EndIf WEnd ;Button1 is pressed... func action1 () ;show GUI2 then don't wait around GUISetState(@SW_SHOW,$GUI2) $bGUI2Active = 1 endfunc ;when button2 is pressed this function IS NOT CALLED func action2 () MsgBox(0,"OK","You pressed button2") endfuncHummm, so you can't call a new function untill after action 1 is returned... here's the thing- in my actual code it goes somthing like this- (sorry for the wierd formating but it gets the point across i hope...the actual script is over 1200 lines )- Pseudocode- <script start> <Makes 2 GUIs> <Show GUI 1> <Loop forever (wait for event from GUI 1 to be called)> ----------- <event from GUI1 is called> <Hide GUI1, show GUI2> <GUI2 has a button that is set to call function "pausef" <A long series of actions is performed, after every few lines I add a check to see if $pause=1, if it does it calls the 'wait' function> ----------- function pausef if $pause=0 then $pause=1 else $pause=0 endif endfunc --------------- func wait while 1 sleep(1000) if $pause=0 return wend endfunc Edited June 27, 2006 by evilertoaster
Nomad Posted June 27, 2006 Posted June 27, 2006 You are trying to create 2 main GUIs, the problem is there somewhere. I don't think you can have 2 main GUIs, only a Parent and then children of that parent. There is nothing wrong with the coding for the button creation or the events as far as I can tell. Nomad
kcd-clan Posted June 27, 2006 Posted June 27, 2006 so u just want a pause function? Visit mEMy programs made.Iul - IulG-V Console - G-V Console_RandomLetter - _RandomLetter()Saftey Kill - Saftey Killcolorzone() = colorzone()
kcd-clan Posted June 27, 2006 Posted June 27, 2006 You can do somthing like in your case just set it with it to where the buttion reacts function. HotKeySet("{PAUSE}","pause") Func pause() ToolTip("paused") $pause=1 Do HotKeySet("{PAUSE}","pause1") Until $pause=0 HotKeySet("{PAUSE}","pause") EndFunc Func pause1() $pause=0 ToolTip("") EndFunc While 1 WEnd Visit mEMy programs made.Iul - IulG-V Console - G-V Console_RandomLetter - _RandomLetter()Saftey Kill - Saftey Killcolorzone() = colorzone()
evilertoaster Posted June 27, 2006 Author Posted June 27, 2006 You are trying to create 2 main GUIs, the problem is there somewhere. I don't think you can have 2 main GUIs, only a Parent and then children of that parent.There is nothing wrong with the coding for the button creation or the events as far as I can tell.Nomad you can have 1024 GUIs according to the help file
evilertoaster Posted June 27, 2006 Author Posted June 27, 2006 You can do somthing like in your case just set it with it to where the buttion reacts function. HotKeySet("{PAUSE}","pause") Func pause() ToolTip("paused") $pause=1 Do HotKeySet("{PAUSE}","pause1") Until $pause=0 HotKeySet("{PAUSE}","pause") EndFunc Func pause1() $pause=0 ToolTip("") EndFunc While 1 WEndyes in fact i already have this. The problem is making it work from a gui button
Nomad Posted June 27, 2006 Posted June 27, 2006 you can have 1024 GUIs according to the help file But does it say "Parent" GUI's? I only tried what you are trying to do one time, and the controls failed to respond. Since then I always create 1 parent and as many children as I need and haven't had a single problem like this since.Nomad
evilertoaster Posted June 27, 2006 Author Posted June 27, 2006 But does it say "Parent" GUI's? I only tried what you are trying to do one time, and the controls failed to respond. Since then I always create 1 parent and as many children as I need and haven't had a single problem like this since.Nomad I've never really worked with 'parent' or 'child' GUIs...I just make GUI windows ....I'll look into it then (it's in the help file i'm guessing?)
Nomad Posted June 27, 2006 Posted June 27, 2006 I've never really worked with 'parent' or 'child' GUIs...I just make GUI windows ....I'll look into it then (it's in the help file i'm guessing?) Yeah, it's not difficult, the child GUI gets named just like a parent GUI, only the last parameter of the child GUICreate() is the name of the parent GUI. Besides that, I have no idea why your, or my, controls failed to work properly.If someone has created more than one parent GUI at the same time and has no problem operating the controls on either GUI, I'd like to see the script.
evilertoaster Posted June 27, 2006 Author Posted June 27, 2006 hummm still doesn't seem to be working directly... opt("GUIONEVENTMODE",1) $a=GUICreate("Test") GUICtrlCreateButton("but1",15,15) GUICtrlSetOnEvent(-1,"f1") $b=GUICreate("Test2",135,135,5,5,"","",$a) GUICtrlCreateButton("but2",5,5) GUICtrlSetOnEvent(-1,"f2") GUISetState(@SW_SHOW,$a) While 1 Sleep(100) WEnd func f1() GUISetState(@SW_SHOW,$B) while 1 Sleep(1000) WEnd EndFunc func f2() MsgBox(0,"OK","OK"); Still not called.... EndFunc although maybe like he said it can't call another function until it returns from the first one? or can am i doing this parent child thing worng?
kcd-clan Posted June 27, 2006 Posted June 27, 2006 Im working on it and it can be done. It will pause gui1 and you can still execute other gui Visit mEMy programs made.Iul - IulG-V Console - G-V Console_RandomLetter - _RandomLetter()Saftey Kill - Saftey Killcolorzone() = colorzone()
evilertoaster Posted June 27, 2006 Author Posted June 27, 2006 Im working on it and it can be done.It will pause gui1 and you can still execute other guiOK...That's kinda what im after i think...(not pausing the GUI per say but rather the whole script flow itself)...what a nussence
Nomad Posted June 27, 2006 Posted June 27, 2006 OK...That's kinda what im after i think...(not pausing the GUI per say but rather the whole script flow itself)... what a nussence This works: opt("GUIONEVENTMODE",1) $a = GUICreate("Test") GUICtrlCreateButton("but1",15,15) GUICtrlSetOnEvent(-1,"f1") $b = GUICreate("Test2",135,135,5,5,-1,"",$a) GUICtrlCreateButton("but2",5,5) GUICtrlSetOnEvent(-1,"f2") GUISetState(@SW_SHOW, $a) While 1 Sleep(100) WEnd func f1() GUISetState(@SW_SHOW, $B) EndFunc func f2() MsgBox(0,"OK","OK"); Still not called.... EndFunc
nitekram Posted June 27, 2006 Posted June 27, 2006 OK...That's kinda what im after i think...(not pausing the GUI per say but rather the whole script flow itself)... what a nussence I wrote something that does this - but I have not updated the code in a while, so there is a lot of extra code that is not needed, but I think it might help. By the way if someone could knock it down and show me all the things that I did wrong - I would be greatful. what is the command to insert long code 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
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