jeffkj Posted June 2, 2010 Share Posted June 2, 2010 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.expandcollapse popup#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 More sharing options...
E1M1 Posted June 2, 2010 Share Posted June 2, 2010 for pwassowrd use $password = InputBox("Password","Please enter password","","*") If $password = "abc123" Then MsgBox(0,"Correct","") Else MsgBox(0,"Try again","") EndIf edited Link to comment Share on other sites More sharing options...
GEOSoft Posted June 2, 2010 Share Posted June 2, 2010 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 More sharing options...
jeffkj Posted June 3, 2010 Author Share Posted June 3, 2010 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. 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 More sharing options...
BitByteBit Posted June 3, 2010 Share Posted June 3, 2010 (edited) Take a look at the macros in the help file. AutoIt has a Shutdown() function which is a bit cleaner to use. If @Hour = 16 then ShellExecute(@WindowsDir&"\System32\Shutdown.exe", "-t 0 -s") Edited June 3, 2010 by BitByteBit Link to comment Share on other sites More sharing options...
Fire Posted June 3, 2010 Share Posted June 3, 2010 or #RequireAdmin RunWait("cmd.exe /c " & "at 16:00 /interactive %systemroot%\system32\shutdown -t -0 -s",@SystemDir,@SW_HIDE) #cs 24-hour clock 12-hour clock 16:00 4:00 p.m #ce [size="5"] [/size] Link to comment Share on other sites More sharing options...
GEOSoft Posted June 3, 2010 Share Posted June 3, 2010 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 More sharing options...
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