Jump to content

Exit Button


Rabbitman
 Share

Recommended Posts

I cant get the exit button at the top right to exit. I think the function is GUI_EVENT_CLOSE but when i put it in my script it says unable to parse function call. Its the only thing i have put in so far... and i want to make it work with hotkeys. What should i do?

Script:

Opt('MustDeclareVars', 1)
Bye()
Func Bye()
    Local $msg
    GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    EndFunc
Link to comment
Share on other sites

I had to add two lines to get it to work as I think you'd like it. The first is "#include<GUIConstantsEx.au3>" Which is probably the reason you got the error The second is GUICreate("Test") as you hadn't made a GUI... I assume you weren't posting the whole code? Right now it doesn't actually exit as such, it just returns from the program. It is possible that if you have more code after Bye() then it will carry on going and won't exit.

Opt('MustDeclareVars', 1)

#include<GUIConstantsEx.au3>

GUICreate("Test")

Bye()

Func Bye()
    Local $msg
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Bye
Link to comment
Share on other sites

I had to add two lines to get it to work as I think you'd like it. The first is "#include<GUIConstantsEx.au3>" Which is probably the reason you got the error The second is GUICreate("Test") as you hadn't made a GUI... I assume you weren't posting the whole code? Right now it doesn't actually exit as such, it just returns from the program. It is possible that if you have more code after Bye() then it will carry on going and won't exit.

Opt('MustDeclareVars', 1)

#include<GUIConstantsEx.au3>

GUICreate("Test")

Bye()

Func Bye()
    Local $msg
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Bye

Really Mat?

Why share code that is malformed and bad practise?

Link to comment
Share on other sites

Really Mat?

Why share code that is malformed and bad practise?

OP wanted to know what was wrong with the code, so I made it work and pointed out what could be wrong. It may not be how I'd write it... Does he really want me to reply with my template GUI?

#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 4 -w 5 -w 6

#include<GUIConstantsEx.au3>

_Main()

Func _Main()
    Local $hGUI, $iMsg

    $hGUI = GUICreate("Template GUI")


    GUISetState(@SW_SHOW, $hGUI)

    While 1
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                ExitLoop
        EndSelect
    WEnd

    GUIDelete($hGUI)
    Exit
EndFunc   ;==>_Main
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...