Sign in to follow this  
Followers 0
Jimbei

GUICreate Troubles

5 posts in this topic

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)

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by reb

MEASURE TWICE - CUT ONCE

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 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]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0