Chobyhy Posted August 22, 2007 Share Posted August 22, 2007 (edited) Can you run two loops at once? (Example: While) I'm currently trying to test this code out but its not working properly, infact it would close right after being opened. Heres the code #include <GUIConstants.au3> GUICreate("Test", 500, 300) GUISetState(@SW_SHOW) $Menu_File = GUICtrlCreateMenu("&File") $Test = GUICtrlCreateMenuItem("Test", $Menu_File) $Switch1 = 0 While 1 $msg = GUIGetMsg() Select Case $msg = $Test $Switch1 = 1 EndSelect WEnd While $Switch1 = 1 $B1 = GUICtrlCreateLabel("Test", 5, 5) $B2 = GUICtrlCreateInput("Test2", 20, 20) $B3 = GUICtrlCreateButton("Delete", 50, 50) If $msg = $B3 Then GUICtrlDelete($B1) GUICtrlDelete($B2) GUICtrlDelete($B3) EndIf WEnd Edited August 22, 2007 by Chobyhy Link to comment Share on other sites More sharing options...
Paulie Posted August 22, 2007 Share Posted August 22, 2007 No, You cannot run two loops simultaneously without running multiple scripts. Autoit is not Multi-threaded, and probably will never be... at least not in the near future. you can however edit your code like this, and it should work ok: While 1 $msg = GUIGetMsg() Select Case $msg = $Test $Switch1 = 1 EndSelect If $Switch1 = 1 Then $B1 = GUICtrlCreateLabel("Test", 5, 5) $B2 = GUICtrlCreateInput("Test2", 20, 20) $B3 = GUICtrlCreateButton("Delete", 50, 50) If $msg = $B3 Then GUICtrlDelete($B1) GUICtrlDelete($B2) GUICtrlDelete($B3) EndIf EndIf WEnd Link to comment Share on other sites More sharing options...
Chobyhy Posted August 22, 2007 Author Share Posted August 22, 2007 Problem with your version is it will keep creating new CtrlGui as long as var = 1 and its impossible to use the textbox Link to comment Share on other sites More sharing options...
Paulie Posted August 22, 2007 Share Posted August 22, 2007 Problem with your version is it will keep creating new CtrlGui as long as var = 1 and its impossible to use the textboxBut (Had autoit been able to run 2 loops at once) yours would have been doing the same thing....I simply was demonstrating how to edit the loops to function as 1, I never tested any of it. Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 22, 2007 Share Posted August 22, 2007 A classic case for GuiOnEventMode: #include <GUIConstants.au3> Global $hGUI, $Menu_File, $Test, $B1, $B2, $B3 Opt("GuiOnEventMode", 1) GUICreate("Test", 500, 300) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") $Menu_File = GUICtrlCreateMenu("&File") $Test = GUICtrlCreateMenuItem("Test", $Menu_File) GUICtrlSetOnEvent(-1, "_Menu_Test") GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd Func _Quit() Exit EndFunc ;==>_Quit Func _Menu_Test() $B1 = GUICtrlCreateLabel("Test", 5, 5) $B2 = GUICtrlCreateInput("Test2", 20, 20) $B3 = GUICtrlCreateButton("Delete", 50, 50) GUICtrlSetOnEvent(-1, "_Button_Delete") EndFunc ;==>_Menu_Test Func _Button_Delete() GUICtrlDelete($B1) GUICtrlDelete($B2) GUICtrlDelete($B3) EndFunc ;==>_Button_Delete Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Chobyhy Posted August 22, 2007 Author Share Posted August 22, 2007 Thanks PSaltyDS. Never tried programming it in OnEvent, it looks so confusing... 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