Sign in to follow this  
Followers 0
ThreatLvlPurple

Un-disable Windows close command

3 posts in this topic

I'm new to this, and its my first project, and somehow i managed to disable the close command (both ALT+F4, and the X button) and don't know how.

I found several post talking about disabling it, but none on enabling them.

The code is unfinished, and won't do anything except make some boxes with buttons.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
global $msgboxvar1
global $msgboxvar2
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Form1", 231, 215, 462, 210,-1)
$Button1 = GUICtrlCreateButton("Button1", 24, 136, 89, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Button2", 120, 136, 81, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
call ("Main");calls main, needed to get anything to stay on screen
#EndRegion ### END Koda GUI section ###

func Main () ;gives 2 choices, calls functions based on button hit. then loops on self if ok is hit.
    while 1
    $nMsg = GUIGetMsg(0)
        Switch $nMsg
        Case $Button1
            call ("Mortgagedec")
            Exit
        case $button2
            call ("CreditCarddec")
            Exit
        EndSwitch
    WEnd
endfunc

func Mortgagedec ()
    local $WS_GROUP_Mort
    $msgboxvar1 = GUICreate("Form2", 140, 215, 462, 210)
    $MortButt1 = GUICtrlCreateButton("Find Var1", 24, 80, 89, 25, $WS_GROUP_Mort)
    $MortButt2 = GUICtrlCreateButton("Find Var2",24, 110, 89, 25, $WS_GROUP_Mort)
    $MortButt3 = GUICtrlCreateButton("Leave", 24, 140, 89, 25, $WS_GROUP_Mort)
    GUISetState(@SW_SHOW)
    GuiSetState($GUI_Event_Close)
    while 1
        $Mortmsg = GUIGetMsg()
        switch $Mortmsg
            case $MortButt1
                call ("MortVar1")
                Exit
            case $MortButt2
                call ("MortVar2")
                exit
            case $MortButt3
                GUIDelete()
                call ("Main")
                exit

    if $msgboxvar1 == 1 Then; the if makes it return to  Main
        call ("Main")
    endif
EndSwitch
WEnd
EndFunc
func CreditCarddec ()
    $msgboxvar2 = msgbox (1,"cc","Credit Card")
    if $msgboxvar2 == 1 Then ;The if makes it return to main.
        call ("Main")
        endif
    EndFunc
    Func MortVar1 ()
    ;logic for Var1
EndFunc
func MortVar2 ()
;logic for Var2
EndFunc

Any help would be appreciated.

Also, some of the code comes from the forum and the examples, so i can't explain parts of it. Probably why i can't fix it:)

Share this post


Link to post
Share on other sites



You are missing a "Close Event" in your switch statement.

func Main () ;gives 2 choices, calls functions based on button hit. then loops on self if ok is hit.
    while 1
    $nMsg = GUIGetMsg()
        Switch $nMsg
        Case $Button1
            call ("Mortgagedec")
            Exit
        case $button2
            call ("CreditCarddec")
            Exit
        Case $GUI_Event_Close
            Exit
        EndSwitch
    WEnd
endfunc

Also, for what your doing you don't need to be using the call() command. If you want to call a function just type the name of the function.

ex : Mortgagedec() instead of call("Mortgagedec").

Share this post


Link to post
Share on other sites

Please see, and run the example for GUIGetMsg in the helpfile, it should be clear what you need to do :D

Also I can just by skimming through your code see a few more things...

  • You use Call, in the wrong way, in fact you shouldn't use it at all, just call the functions like you do the native ones. See Language Reference - User Functions.
  • Unnecessary use of case-sensitive comparisons. See Language Reference - Operators in helpfile.
  • Recursion. Your Main() call CreditCarddec() which again calls Main(). That is begging for trouble and AutoIt will crash eventually.
You seem to be new to AutoIt, so I recommend you take a look at some of the tutorials listed in the wiki.

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