你好:

     感谢你访问我的 Blog ,本博客只提供博主的技术经验分享,你可以在此做简单的留言和评论,我会抽空回复你;若是要深入交流探讨,请联系QQ:47853253或者加QQ群:12012081


 

【AU3】脚本--挂机锁脚本

 #NoTrayIcon

#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=..\..\..\Windows\syswow64\SHELL32.dll|-48
#AutoIt3Wrapper_Outfile=Lock.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Description=挂机锁
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p
#AutoIt3Wrapper_Res_LegalCopyright=Jearry
#AutoIt3Wrapper_Res_Language=2057
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_UseAnsi=y
#Region
#EndRegion 
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <Date.au3>
 
Opt("MustDeclareVars", 1)  ;必需声明
Opt("GUICloseOnESC", 0)  ;禁止ESC退出
HotKeySet("!{F4}", "NotF4")
HotKeySet("!{Tab}", "NotTab")
#cs
If @OSVersion <> "WIN_2003" And @OSVersion <> "WIN_XP" And @OSVersion <> "WIN_7" And @OSVersion <> "WIN_2000"Then
MsgBox(262144, "友情提示:", "此软件不能在您的操作系统上运行!")
Exit
EndIf
#ce
Global $LockReg = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\PCLook", "PCLookRun")
If $LockReg <> 1 Then
_PASS()  ;密码输入
EndIf
Global $LockForm, $LockLabel
Global $OpenLock, $OpenStatusBar, $OpenPartsWidth, $OpenLabel, $OpenPass, $OpenButtonOK
Global $Timer1, $TimerDLL1, $Timer2, $TimerDLL2, $OLDT, $NEWT
Global $OpenReg = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\PCLook", "PassWord")
#Region ### START Koda GUI section ### Form= 背景
$LockForm = GUICreate("PCLockForm", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
GUISetBkColor(0x555588)
; WinSetTrans("PCLockForm", "", 170)  ;设置透明度
$LockLabel = GUICtrlCreateLabel("铜川网吧,欢迎您!", 10, @DesktopHeight/2.5, @DesktopWidth, @DesktopWidth/5.12, $SS_CENTER)
GUICtrlSetFont(-1, @DesktopWidth/15, 400, 0, "方正粗活意简体")
GUICtrlSetColor(-1, 0xffff00)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
#Region ### START Koda GUI section ### Form= 密码解锁
$OpenLock = GUICreate("密码解锁", @DesktopWidth/3.96, @DesktopHeight/7.83, @DesktopWidth/1.34, @DesktopHeight/1.15, BitOR($WS_SYSMENU, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER), BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
$OpenLabel = GUICtrlCreateLabel("请输入解锁密码,进行解锁。", 0, 10, @DesktopWidth/4, @DesktopHeight/45.17, $SS_CENTER)
GUICtrlSetColor(-1, 0xff0000)
$OpenPass = GUICtrlCreateInput("", @DesktopWidth/48.76, @DesktopHeight/25.6, @DesktopWidth/4.7, @DesktopHeight/45.17, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL), $WS_EX_STATICEDGE)
    GUICtrlSetState(-1, $GUI_FOCUS)
GUICtrlSetCursor(-1, 5)
$OpenButtonOK = GUICtrlCreateButton("确  定", @DesktopWidth/5.68, @DesktopHeight/14.76, @DesktopWidth/17, @DesktopHeight/32, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
$OpenStatusBar = _GUICtrlStatusBar_Create($OpenLock)
Dim $OpenPartsWidth[2] = [@DesktopWidth/6.4, -1]
_GUICtrlStatusBar_SetParts($OpenStatusBar, $OpenPartsWidth)
_GUICtrlStatusBar_SetText($OpenStatusBar, "已被锁定,需要密码才能进入。", 0)
_GUICtrlStatusBar_SetText($OpenStatusBar, _Now(), 1)
_GUICtrlStatusBar_SetMinHeight($OpenStatusBar, 11)
_GUICtrlStatusBar_SetBkColor($OpenStatusBar, 0x599FEC)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
$Timer1 = DllCallbackRegister("_Timer", "int", "hwnd;uint;uint;dword")
$TimerDLL1 = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 1, "ptr", DllCallbackGetPtr($Timer1))
$Timer2 = DllCallbackRegister("_Timer", "int", "hwnd;uint;uint;dword")
$TimerDLL2 = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 5000, "ptr", DllCallbackGetPtr($Timer2))
 
While 1
$OLDT = _GUICtrlStatusBar_GetText($OpenStatusBar, 1)  ;系统时间
$NEWT = _Now()
if $NEWT <> $OLDT Then _GUICtrlStatusBar_SetText($OpenStatusBar, _Now(), 1)
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $OpenButtonOK
If GUICtrlRead($OpenPass) = "" Then
GUICtrlSetData($LockLabel, " 密 码 错 误 !")
GUICtrlSetState($OpenPass, $GUI_FOCUS)
ElseIf GUICtrlRead($OpenPass) <> $OpenReg Then
GUICtrlSetData($LockLabel, " 密 码 错 误 !")
GUICtrlSetState($OpenPass, $GUI_FOCUS)
Else
Quit()
EndIf
EndSwitch
WEnd
 
Func _PASS()
Local $PassForm, $PassLabelTat, $PassLabel1, $PassLabel2, $PassInput1, $PassInput2, $PassButtonOK, $PassButtonExit
Local $PassReg = "HKEY_LOCAL_MACHINE\SOFTWARE\PCLook"
FileInstall("方正粗活意简体.ttf", @TempDir&"\Fz.ttf", 1)
;FileCreateShortcut(@ScriptFullPath, @DesktopDir&"\挂机锁.lnk", @ScriptDir)  ;快捷方式
;RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "PCLook", "REG_SZ", @ScriptFullPath)  ;启动项
InstallFonts(@TempDir&"\Fz.ttf", "方正粗活意简体")  ;字体安装
#Region ### START Koda GUI section ### Form= 密码输入锁定
$PassForm = GUICreate("输入密码!", @DesktopWidth/3.96, @DesktopHeight/7.83, @DesktopWidth/2-129, @DesktopHeight/2-52, BitOR($WS_SYSMENU, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER))
$PassLabelTat = GUICtrlCreateLabel("请输入挂机锁密码,并牢记。", 0, 5, @DesktopWidth/4, @DesktopHeight/45.17, $SS_CENTER, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetColor(-1, 0xff0000)
$PassLabel1 = GUICtrlCreateLabel("输入密码:", @DesktopWidth/128, @DesktopHeight/29.5, @DesktopWidth/11.9, @DesktopHeight/45.17, -1, $GUI_WS_EX_PARENTDRAG)
$PassLabel2 = GUICtrlCreateLabel("重复输入密码:", @DesktopWidth/128, @DesktopHeight/15.6, @DesktopWidth/11.9, @DesktopHeight/45.17, -1, $GUI_WS_EX_PARENTDRAG)
$PassInput1 = GUICtrlCreateInput("", @DesktopWidth/11.25, @DesktopHeight/32, @DesktopWidth/6.52, @DesktopHeight/45.17, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL), $WS_EX_STATICEDGE)
GUICtrlSetState(-1, $GUI_FOCUS)
$PassInput2 = GUICtrlCreateInput("", @DesktopWidth/11.25, @DesktopHeight/16.3, @DesktopWidth/6.52, @DesktopHeight/45.17, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL), $WS_EX_STATICEDGE)
$PassButtonOK = GUICtrlCreateButton("确  定", @DesktopWidth/8.6, @DesktopHeight/11, @DesktopWidth/17, @DesktopHeight/32, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
$PassButtonExit = GUICtrlCreateButton("退  出", @DesktopWidth/5.4, @DesktopHeight/11, @DesktopWidth/17, @DesktopHeight/32, $WS_GROUP, $WS_EX_STATICEDGE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $PassButtonExit
Exit
Case $PassButtonOK
If GUICtrlRead($PassInput1) <> GUICtrlRead($PassInput2) Then
_WinAPI_MsgBox_UDF($PassForm, "输入错误:", "两次输入密码不相同。", 0)
GUICtrlSetState($PassInput1, $GUI_FOCUS)
ElseIf GUICtrlRead($PassInput1) = "" And GUICtrlRead($PassInput2) = "" Then
_WinAPI_MsgBox_UDF($PassForm, "输入错误:", "您尚未输入密码,请重试。", 0)
GUICtrlSetState($PassInput1, $GUI_FOCUS)
Else
RegWrite($PassReg, "PassWord", "REG_SZ", GUICtrlRead($PassInput1))
;RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\PCLook", "PCLookRun", "REG_SZ", "1")  ;写入开机启动
;==禁用任务管理器
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", "1")
                RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableLockWorkstation", "REG_DWORD", "0")
Send("#m")
ExitLoop
EndIf
EndSwitch
WEnd
GUIDelete($PassForm)
EndFunc
 
Func _WinAPI_MsgBox_UDF($hWnd, $Title, $Text, $Flag)   ;API对话框
Local $aResult
$aResult=DllCall("user32.dll","int","MessageBox","hwnd",$hWnd,"str", $Text,"str",$Title,"int",$Flag)
If @error Then Return SetError(@error, 0, False)
Return $aResult[0]
EndFunc  ;==>_WinAPI_MsgBox_UDF
 
Func _Timer($hWnd, $uiMsg, $idEvent, $dwTime)     ;多线程
If $idEvent = $TimerDLL1[0] Then
Local $coords = WinGetPos($OpenLock)  ;返回窗口大小
_MouseTrap($coords[0], $coords[1], $coords[0] + $coords[2], $coords[1] + $coords[3])  ;锁定鼠标
If Not WinActive("密码解锁") Then WinActivate("密码解锁")  ;窗口激活
If ProcessExists("taskmgr.exe") Then ProcessClose("taskmgr.exe")
ElseIf $idEvent = $TimerDLL2[0] Then
If GUICtrlRead($LockLabel) = " 密 码 错 误 !" Then
GUICtrlSetData($LockLabel, "铜川网吧,欢迎您!")
ElseIf _GUICtrlStatusBar_GetText($OpenStatusBar, 0) = "密码不能为空!~" Then
_GUICtrlStatusBar_SetText($OpenStatusBar, "已被锁定,需要密码才能进入。", 0)
ElseIf _GUICtrlStatusBar_GetText($OpenStatusBar, 0) = "已被锁定,需要密码才能进入。" Then
_GUICtrlStatusBar_SetText($OpenStatusBar, "铜川网吧,欢迎您!", 0)
ElseIf _GUICtrlStatusBar_GetText($OpenStatusBar, 0) = "铜川网吧,欢迎您!" Then
_GUICtrlStatusBar_SetText($OpenStatusBar, "小飞网络,荣誉出品。", 0)
ElseIf _GUICtrlStatusBar_GetText($OpenStatusBar, 0) = "小飞网络,荣誉出品。" Then
_GUICtrlStatusBar_SetText($OpenStatusBar, "已被锁定,需要密码才能进入。", 0)
EndIf
EndIf
EndFunc  ;==>_Timer()
 
Func InstallFonts($sSourceFile, $sFontDescription)  ;字体安装
    Local Const $HWND_BROADCAST = 0xFFFF
    Local Const $WM_FONTCHANGE = 0x1D
    Local $sFontFileName = StringRegExpReplace($sSourceFile, '^.*\\', '')
    If Not FileCopy($sSourceFile, @WindowsDir & "\fonts\" & $sFontFileName, 1) Then Return SetError(1, 0, 0) 
    Local $aRet = DllCall("gdi32.dll", "Int", "AddFontResource", "str", @WindowsDir & "\fonts\" & $sFontFileName)
    If IsArray($aRet) And $aRet[0] > 0 Then
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", $sFontDescription, "REG_SZ", $sFontFileName)
        DllCall("user32.dll", "Int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_FONTCHANGE, "int", 0, "int", 0)
        Return 1
    EndIf
    Return SetError(2, 0, 0)
EndFunc  ;==>InstallFonts()
 
Func Quit()
;==开启任务管理器
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", "0")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableLockWorkstation", "REG_DWORD", "1")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\PCLook", "PCLookRun", "REG_SZ", "0")  ;解除开机启动
RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "PCLook")
Exit
EndFunc
 
Func NotF4()
 
EndFunc
 
Func NotTab()
 
EndFunc


文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
评论: 0 | 引用: 0 | 查看次数: 104
发表评论
你没有权限发表留言!