Jump to content

Prevent gui close and require password


Recommended Posts

Hello-

I am extremely new at this, so needless to say, I don't really know what I'm doing yet. I'm trying to make a shell replacement menu for the sole purpose of connecting to a terminal server at the school district here. I'm time pressed, since summer school is starting next week. I was hoping someone may be able to help me accomplish a couple of items I've been trying to figure out how to do. I want to disable the GUI closing when someone presses ALT+F4, and also require a password to be entered before any of the items in the "Options" menu are executed.

Thanks in advance to anyone who takes the time to help.

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
    Local $optionmenu, $configureitem, $controlitem, $commanditem
    Local $helpmenu, $aboutitem, $connectbutton, $shutdownbutton
    Local $msg, $file, $WS_POPUPWINDOW

    

    GUICreate("Pocatello/Chubbuck School District 25", 300, 225,-1,-1,$WS_POPUPWINDOW)

    $optionmenu = GUICtrlCreateMenu("Options")
    $configureitem = GUICtrlCreateMenuItem("Configure RDP", $optionmenu)
    $controlitem = GUICtrlCreateMenuItem("Control Panel", $optionmenu)
    $commanditem = GUICtrlCreateMenuItem("Command Prompt", $optionmenu)
    $helpmenu = GUICtrlCreateMenu("?")
    $aboutitem = GUICtrlCreateMenuItem("About", $helpmenu)

    $connectbutton = GUICtrlCreateButton("Click Here To Log In", 50, 40, 205, 60)

    $shutdownbutton = GUICtrlCreateButton("Shutdown Computer", 65, 140, 177, 20)
        GUISetState()

    While 1
        $msg = GUIGetMsg()


        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop

            Case $msg = $configureitem
                Run("c:\windows\system32\mstsc.exe")

            Case $msg = $controlitem
                Run("c:\windows\system32\control.exe")
                
            Case $msg = $commanditem
                Run("c:\windows\system32\cmd.exe")

            Case $msg = $connectbutton
                Run("c:\windows\system32\mstsc.exe c:\rdpserver.rdp")

            Case $msg = $shutdownbutton
                Run("shutdown.exe -t 0 -s")

            Case $msg = $aboutitem
                MsgBox(0, "About", "Created by Jeff Jolley")

        EndSelect
    WEnd

    GUIDelete()

EndFunc   ;==>_Main
Link to comment
Share on other sites

and to solve the whole probelm. Just put the code E1M1 gave you in a function and register it with OnAutoItExitRegister()at the beginning of the script.

OnAutoItExitRegister("_Bye")
;; Your code goes here

Func _Bye();; Modified version of E1M1s code
    If InputBox("Password","Please enter password","","*") = "abc123" Then
        Exit
    EndIf
    Return
EndFunc

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

and to solve the whole probelm. Just put the code E1M1 gave you in a function and register it with OnAutoItExitRegister()at the beginning of the script.

OnAutoItExitRegister("_Bye")
;; Your code goes here

Func _Bye();; Modified version of E1M1s code
    If InputBox("Password","Please enter password","","*") = "abc123" Then
        Exit
    EndIf
    Return
EndFunc

Thank you both TONS for that. It really helped. :mellow: Now, one more question if you have a moment, Is there a way I can add a function to my script to execute a program at a specified time? I want to run "c:\windows\system32\shutdown.exe -t 0 -s" at 4pm daily.

Thanks again,

Jeff

Link to comment
Share on other sites

While 1
    If @Hour = 16 Then ShutDown(17)
    Sleep(50)
WEnd

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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...