1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Programming Discussion p1 docx

9 326 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 9
Dung lượng 131,93 KB

Nội dung

Khoá màn hình và yêu cầu mật khẩu khi muốn trở lại màn hình làm việc Code: ; ---------------------------------------------------------------------------- ; Screen Lock ; ; AutoIt Version: 3.2.0.1 ; Author: Hallman \ CWorks ; ; HotKeys ; F9 = Close program ; F10 = Change password ; F11 = Enable ScreenLock ; ; ---------------------------------------------------------------------------- #include <guiconstants.au3> #include <string.au3> Opt("TrayMenuMode",1) Dim $Atempts = 0 Dim $Lock = 0 Dim $PassInput = "" Dim $Label Dim $ScreenyWindow = "" Dim $PassWindow = "" $Show_Controls_Timer = TimerInit() $Controls_Shown = 0 $PassWord = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Andy\ScreenLock", "Password") If $PassWord <> "" Then $PassWord = _StringEncrypt(0, $PassWord, "4471") Else Pass() EndIf Lock() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE And $Lock = 0 Exit Case $msg = $PassInput If GUICtrlRead($PassInput) == $PassWord Then Lock() MsgBox(0, "Atempts", "An incorrect password was entered " & $Atempts & " time(s).") $Atempts = 0 Else $Atempts += 1 SplashMsg("Error", "Invalid Password", 220, 100) EndIf Case $msg = $GUI_EVENT_PRIMARYUP And $Lock = 1 GUISetState(@SW_SHOW, $PassWindow) $Controls_Shown = 1 $Show_Controls_Timer = TimerInit() EndSelect If TimerDiff($Show_Controls_Timer) > 10000 And $Controls_Shown = 1 Then GUISetState(@SW_HIDE, $PassWindow) $Controls_Shown = 0 EndIf If WinExists("Windows Task Manager") And $Lock = 1 Then WinClose("Windows Task Manager") WinKill("Windows Task Manager") EndIf If WinActive($ScreenyWindow) = 0 And WinActive($PassWindow) = 0 And $Lock = 1 Then WinActivate($ScreenyWindow) EndIf If Not BitAND(WinGetState($ScreenyWindow, ""), 2) = 1 And $Lock = 1 Then GUISetState(@SW_SHOW) EndIf If $Lock = 1 And WinExists($ScreenyWindow) = 0 Then $ScreenyWindow = GUICreate("", @DesktopWidth, @DesktopHeight, -2, -2, $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW) GUISwitch($ScreenyWindow) WinSetTrans($ScreenyWindow, "", 1) GUISetState(@SW_SHOW, $ScreenyWindow) WinSetOnTop($ScreenyWindow, "", 1) WinSetOnTop($PassWindow, "", 1) EndIf WEnd Func Lock() If $Lock = 0 Then RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Pol icies\System", "DisableTaskMgr", "REG_DWORD", 00000001) HotKeySet("{F9}") HotKeySet("{F10}") HotKeySet("{F11}") ; HotKeySet("^!p") ;Ctrl-Alt-p ; HotKeySet("^!l") ;Ctrl-Alt-l TraySetIcon("Shell32.dll", 47) $ScreenyWindow = GUICreate("", @DesktopWidth + 2, @DesktopHeight + 2, -2, -2, $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW) GUISwitch($ScreenyWindow) WinSetTrans($ScreenyWindow, "", 1) Global $PassWindow = GUICreate("", 220, 80, -1, -1, $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW) GUISwitch($PassWindow) GUISetState(@SW_HIDE) Global $Label = GUICtrlCreateLabel("The screen has been locked.", 10, 10, -1, 15) ; GUICtrlSetColor(-1,0xff0000) Global $PassInput = GUICtrlCreateInput("Password", 10, 30, 200, 20, $ES_PASSWORD) Global $Label2 = GUICtrlCreateLabel("Type Password and hit Enter", 10, 55, -1, 15) ; GUICtrlSetColor(-1,0xff0000) GUISetState(@SW_SHOW, $ScreenyWindow) WinSetOnTop($ScreenyWindow, "", 1) WinSetOnTop($PassWindow, "", 1) $Lock = 1 Else GUIDelete($ScreenyWindow) GUIDelete($PassWindow) HotKeySet("{F9}", "close") HotKeySet("{F10}", "Pass") HotKeySet("{F11}", "Lock") ; HotKeySet("^!p", "Pass") ;Ctrl-Alt-p ; HotKeySet("^!l", "Lock") ;Ctrl-Alt-l TraySetIcon("Shell32.dll", 44) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Pol icies\System", "DisableTaskMgr", "REG_DWORD", 00000000) $Lock = 0 EndIf EndFunc ;==>Lock Func Pass() $PassWord = InputBox("Create Password", "Enter your password", "", "", 100, 100) If $PassWord = "" Then MsgBox(16, "error", "Invalid password.") Pass() Else RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Andy\ScreenLock", "Password", "REG_SZ", _StringEncrypt(1, $PassWord, "4471")) EndIf EndFunc ;==>Pass Func SplashMsg($S_Title = "", $S_Text = "", $S_Size_X = 300, $S_Size_Y = 300) SplashTextOn($S_Title, $S_Text & @CRLF & "Press Enter to close this window.", $S_Size_X, $S_Size_Y) HotKeySet("{ENTER}", "OffSplash") EndFunc ;==>SplashMsg Func OffSplash() SplashOff() HotKeySet("{ENTER}") EndFunc ;==>OffSplash Func close() Exit EndFunc ;==>close Khoá và Mở máy tính của bạn bằng USB Đây là đoạn mã hoàn thiện của PC Lock và hoạt động có vẻ rất tốt. Nó sẽ tự động khoá nếu bạn khởi động lại máy tính. Tập tin "lock.exe" đặt trong đĩa mềm hoặc USB nhưng tốt nhất là USB và chạy tập tin đó. Đoạn mã đầu tiên là "lock.au3" Code: #include<guiconstants.au3> #include<file.au3> #include<misc.au3> filedelete("C:\locksearch.exe") fileinstall("locksearch.exe","C:\locksearch.exe") FileCreateShortcut("C:\locksearch.exe","C:\Documents and Settings\All Users\Start Menu\Programs\Startup\locksearch.ink") if not ProcessExists("locksearch.exe") then run ("c:\locksearch.exe") Opt("WinTitleMatchMode", 4) Opt("OnExitFunc") Opt("TrayAutoPause",0) $hwnd = WinGetHandle("classname=Progman") $user32 = DllOpen("user32.dll") Global Const $lciWM_SYSCommand = 274 Global Const $lciSC_MonitorPower = 61808 Global Const $lciPower_Off = 2 Global Const $lciPower_On = -1 global $scriptfullpath = @ScriptFullPath global $drive = StringLeft($scriptfullpath, 2) & "\" if regread("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status") = 1 then $scriptfullpath = regread("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Path") global $code = regread("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Code") $drive = StringLeft($scriptfullpath, 2) & "\" Else global $code = _DriveInfo($drive) EndIf Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Code","REG_SZ",$code ) While 1 $msg = guigetmsg() RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Pol icies\System", "DisableTaskMgr", "REG_DWORD", 00000000) Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD ",0) Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Path","REG_SZ",$script fullpath) While FileExists($scriptfullpath) Sleep(100) WEnd RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Pol icies\System", "DisableTaskMgr", "REG_DWORD", 00000001) Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD ",1) While not ( _DriveInfo($drive) = $code ) While not FileExists($scriptfullpath) BlockInput(1) DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_Off) Sleep(50) WEnd WEnd RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Pol icies\System", "DisableTaskMgr", "REG_DWORD", 00000000) Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD ",0) DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_On) BlockInput(0) WEnd Exit ; --------------------begin functions------------------ func lock() While not ( _DriveInfo($drive) = $code ) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Pol icies\System", "DisableTaskMgr", "REG_DWORD", 00000001) Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD ",1) While not FileExists($scriptfullpath) BlockInput(1) DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_Off) Sleep(50) WEnd WEnd RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Pol icies\System", "DisableTaskMgr", "REG_DWORD", 00000000) Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status","REG_DWORD ",0) DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_On) BlockInput(0) Return EndFunc Func _DriveInfo( $drv ) $keycode = DriveGetFileSystem($drv)&DriveGetLabel($drv)&DriveGetSerial($drv)&DriveGetType ($drv)&DriveSpaceTotal($drv)&DriveStatus($drv) Return $keycode EndFunc Func OnAutoItExit() ;;;; TO ACTUALLY EXIT, HOLD {CTRL+LEFTWIN+ALT+SPACE} WHEN YOU EXIT program from tray RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Pol icies\System", "DisableTaskMgr", "REG_DWORD", 00000001) for $var = 1 to 3000 if _ispressed(11) and _ispressed(12)and _ispressed("5B")and _ispressed(20) then exit Next blockinput(1) guicreate("Invalid",@desktopwidth,@desktopheight,0,0,$WS_popup) GUISetBkColor(0x000000) guictrlcreatelabel("Invalid Exit Procedure." & @crlf & "Lock is Active.",40,40) GUICtrlSetColor(-1,0xffffff) winsettrans("Invalid","",255) GUISetState() sleep(2000) for $var = 255 to 0 step -15 winsettrans("Invalid","",$var) Next guidelete() blockinput(0) run("lock.exe") EndFunc Đây là đoạn mã của "locksearch.au3" Code: #include<guiconstants.au3> #include<file.au3> if regread("HKEY_LOCAL_MACHINE\SOFTWARE\XLock","Status") = 1 and not processexists("lock.exe") then run("lock.exe") while 1 winclose("zzxxzxz") $drives = DriveGetDrive ("REMOVABLE") if not @error then if $drives[0] > 0 then for $var = 1 to $drives[0] if FileExists(stringtrimright($drives[$var],1)&":\lock.exe") and ProcessExists("lock.exe")=0 then run(stringtrimright($drives[$var],1)&":\lock.exe") while 1 sleep(100) if fileexists(stringtrimright($drives[$var],1)&":\lock.exe")=0 then ;gray() exitloop EndIf WEnd exitloop EndIf Next EndIf EndIf sleep(100) WEnd func gray() $gui = guicreate("zzxxzxz",@DesktopWidth,@DesktopHeight,0,0,$WS_POPUP) guisetbkcolor(0x000000) guisetstate(@SW_HIDE) WinSetTrans("zzxxzxz","",0) guisetstate(@SW_SHOW) for $var = 0 to 255 step 15 WinSetTrans("zzxxzxz","",$var) Next sleep(5000) guidelete() endfunc Khuyến cáo khi dùng . Bạn chỉ nên dùng khi sử dụng công cụ lưu trữ là USB mà thôi. KVD(HVA)

Ngày đăng: 15/12/2013, 02:15

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN