Jimbei Posted June 26, 2011 Posted June 26, 2011 I'm having a bit of difficulty with GUICreate. I create a window, but it closes within a fifth of a second. Here's my code: Global $Window $Window = GUICreate("My GUI", 640, 480)
reb Posted June 26, 2011 Posted June 26, 2011 (edited) Global $Window $Window = GUICreate("My GUI", 640, 480) Check out GUISetState() in the help file REB edit Sorry that doesn't work. should have tested before post. Will check it after I take my shower. REB Edited June 26, 2011 by reb MEASURE TWICE - CUT ONCE
AdmiralAlkex Posted June 26, 2011 Posted June 26, 2011 Hi and Welcome to the forums!Is that all your code? Then it's no wonder it disappears as you don't have any loop or something that stops the script from exiting.Open the helpfile and read "GUI Reference", then you atleast have a foundation to build on, then if you're serious with AutoIt you may want to check out some of the tutorials listed on the wiki.Tutorials .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Jimbei Posted June 26, 2011 Author Posted June 26, 2011 I added GUIsetstate to the code, but the problem persists. The help said to add this to keep the window open: ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd I added that to the end, so it looks like this now: Global $Window, $GUI_EVENT_CLOSE $Window = GUICreate("My GUI", 640, 480) GUIsetstate (@SW_SHOW) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd The problem still persists.
Maffe811 Posted June 26, 2011 Posted June 26, 2011 (edited) Its because you declared $GUI_EVENT_CLOSE and didnt add the include file! #include <GUIConstantsEx.au3> Global $Window $Window = GUICreate("My GUI", 640, 480) GUIsetstate (@SW_SHOW) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd How i would do it: #include <GUIConstantsEx.au3> Global $Window $Window = GUICreate("My GUI", 640, 480) GUIsetstate (@SW_SHOW) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Edited June 26, 2011 by Maffe811 [font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]
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