Fewmitz Posted November 6, 2007 Share Posted November 6, 2007 So right now, I have this code: #include <GUIConstants.au3> [...] Opt("GUIOnEventMode", 1 ) GuiCreate("MyGUI", 200, 250,-1, -1 ) $add = GuiCtrlCreateButton("Add", 10, 20, 180, 80) GUICtrlSetOnEvent(-1, "_begin" ) $Edit1 = GUICtrlCreateEdit( "", 0, 100, 200, 150) GuiSetState() But when I run the script, the window flashes, then disappears. What am I doing wrong? ¬_¬ Link to comment Share on other sites More sharing options...
jruelan Posted November 6, 2007 Share Posted November 6, 2007 make a loop so that it will be shown Link to comment Share on other sites More sharing options...
AcidCorps Posted November 6, 2007 Share Posted November 6, 2007 make a loop so that it will be shown Taken from SampleControls.au3 GUI ; GUI MESSAGE LOOP GuiSetState() While GuiGetMsg() <> $GUI_EVENT_CLOSE WEnd Link to comment Share on other sites More sharing options...
Fewmitz Posted November 6, 2007 Author Share Posted November 6, 2007 That is such a bad way to make a programming language. I feel stupid. One more question, though: How would I reference the value in an InputBox? Something like if I wanted to put the value of one in a message box. Link to comment Share on other sites More sharing options...
JustinReno Posted November 6, 2007 Share Posted November 6, 2007 That is such a bad way to make a programming language.No its not, its commom sense. Link to comment Share on other sites More sharing options...
Fewmitz Posted November 6, 2007 Author Share Posted November 6, 2007 No its not, its commom sense.No. Common sense would make it so you don't have to constantly display the form, and just have it up, and you can close it when needed. Link to comment Share on other sites More sharing options...
Vindicator209 Posted November 6, 2007 Share Posted November 6, 2007 (edited) Ah, who said anything about constantly displaying the form? your GUI closes because the script ended, now to stop this, you need a loop, and not only that, if you had buttons, you wouldn't be able to check if it was pressed later if you only check once! The most basic of languages makes the most complex of programs.Edit: (sorry I forgot to answer your question)$var=InputBox("title","prompt") ;Declare a value with the InputBoxMsgBox(0,"title","Your variable is: "&$var) ;Display your boxCheers.P.S. Whats all this about common sense? You need a lot more than just common sense if you want to be serious about scripting Edited November 6, 2007 by MethodZero [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center] Link to comment Share on other sites More sharing options...
Achilles Posted November 6, 2007 Share Posted November 6, 2007 If you didn't start with AutoIt as you're programming language I can see why a constant loop would appear useless. I was looking as VisualBasic some and was surprised by the differences. However, I almost always use GuiOnEvent mode and GuiRegisterMsg so my loop almost always look like this: While 1 Sleep(1000) WEnd My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
toothyXdip Posted November 6, 2007 Share Posted November 6, 2007 (edited) One more question, though: How would I reference the value in an InputBox? Something like if I wanted to put the value of one in a message box. Another example expandcollapse popup#include <GUIConstants.au3> Global $name_input GUICreate("Demo", 200, 200) $name_input = GUICtrlCreateInput("Your Name?", 100, 100, 90, 20) $next = GUICtrlCreateButton("Next", 150, 170, 50, 20) GUISetState(@SW_SHOW) While True $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $next nextbutton() EndSelect WEnd Func nameinput() $inputname = GUICtrlRead($name_input) EndFunc Func nextbutton() Global $inputname = GUICtrlRead($name_input) GUICreate("Demo", 200, 200) $label = GUICtrlCreateLabel("Your name is " & $inputname, 50, 50) GUISetState(@SW_SHOW) While True $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd EndFunc Edited November 6, 2007 by toothyXdip ---╔╦═╗╔╗'''╔╗╔═╦═╗╔╦═╗---╝╠═╣╝║'''║╝╝'''║'''╝╝║'''║......║'''║'''║'''║'''''''''║'''''''''║'''║---╔╩═╩═╩═╩═══╩═╦═╩═╩══╦══════╗''''╔╩════════════╩══╗╔══╩══╗╔══╝ ''''╝''''''''''''''''''''''''''''''''''''''''''''''''║║'''''''''''''''║║ ''''''''''''''''''''''''''''''''''''''''''''''╔══╝╚══╗''''''║║''''''''''''''''''''''''''''''''''''''''''''''╚══════╝''''''╚╝ Link to comment Share on other sites More sharing options...
RobertKipling Posted November 6, 2007 Share Posted November 6, 2007 (edited) If you didn't start with AutoIt as you're programming language I can see why a constant loop would appear useless. I was looking as VisualBasic some and was surprised by the differences. However, I almost always use GuiOnEvent mode and GuiRegisterMsg so my loop almost always look like this: While 1 Sleep(1000) WEnd Correct me if I'm wrong, but that's a shoddy bit of code. With the Sleep command, message events are almost always delayed indefinitely in Windows XP, sometimes making it ridiculously slow. I don't doubt it might work, but for a beginner, a $msg loop is more than enough. Proper code would run more along these lines: While 1 $msg = GUIGetMsg() Switch $msg Case $button ; code... Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd I discovered the Switch loop all too slowly. Edited November 6, 2007 by RobertKipling Link to comment Share on other sites More sharing options...
Richard Robertson Posted November 6, 2007 Share Posted November 6, 2007 The Sleep() function in AutoIt is not the same as the thread sleeping function in Windows. The AutoIt Sleep function allows it to pause the current execution, events will still be triggered, such as hot keys or GUI events (if turned on). Link to comment Share on other sites More sharing options...
Achilles Posted November 7, 2007 Share Posted November 7, 2007 Correct me if I'm wrong, but that's a shoddy bit of code. With the Sleep command, message events are almost always delayed indefinitely in Windows XP, sometimes making it ridiculously slow. I don't doubt it might work, but for a beginner, a $msg loop is more than enough. Proper code would run more along these lines: While 1 $msg = GUIGetMsg() Switch $msg Case $button ; code... Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd I discovered the Switch loop all too slowly.With the GuiOnEvent options the reaction time is possibly faster then using a GuiGetMsg() in your loop. Try using it sometime... I find it makes my code more organized, shorter and cleaner. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] 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