注意,使用此脚本后。如果不输入正确的密码,任务管理器会被禁用。需要到注册表将HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System 设置为0才能解锁

; 改pwd = [password goes here]成自己的密码,输入密码后按回车关闭屏幕保护

; 注意,使用此脚本后。如果不输入正确的密码,任务管理器会被禁用。
; 需要到注册表将HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System 设置为0才能解锁

; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=73108
; ------------------------------
; SCREENSAVER
; This AutoHotkey script creates a screensaver that displays a photo, along with the user's name,
; e-mail address, and telephone number. The user must type a password to exit the script.
; The program waits for invisible keyboard input from the user. A maximum number of attempts is specified.
; If the maximum number of attempts is exceeded, the script will lock the workstation.
; The Windows Task Manager will be disabled while the screensaver is active.
; The password is stored in plain text here, so this script file should be protected against unauthorized access.
; The script will not steal the focus if lost. If the focus is lost, click on the screensaver before entering the password.
; This script can be compiled with Ahk2Exe.
; In the script below, the user can modify placeholders designated with brackets.
; By Michael Weiner on 29 February 2020
; Copyright 2020 Michael Weiner
; ------------------------------
; Personal information: modify placeholders in brackets
name = [name goes here]
email = [e-mail address goes here]
phone = [phone number goes here]
photo = [full path to photo goes here]
icon = [full path to icon goes here] ; This is the tray icon, though the screensaver will actually cover the tray.
pwd = [password goes here] ; To exit this script, user should type this, and then press ENTER.
; ------------------------------
; Variables below can also be modified as needed
maxTries := 3 ; Number of password attempts before locking the workstation
hpad := 70 ; Horizontal padding between photo and text
vpad := 30 ; Vertical padding among name, e-mail address, and phone number
fontName = Arial
fontSize := 30
textColor = White
bkg = 000000 ; Background color (000000 = black)
formWidth := 0 ; Width of zero will make the password entry form invisible
onTop = True ; True if screensaver should stay on top of other windows
taskManager = True ; True if Windows Task Manager should be disabled while screensaver is active
; ------------------------------
; Variables below should not be modified
tries := 0 ; Keep track of the number of password attempts
enable := 0
disable := 1
; ------------------------------

; Do some initial setup
If (pwd = "[password goes here]")
{
 MsgBox, 48, Error, 尚未设置密码。正在中止。
 ExitApp
}
If FileExist(icon)
 Menu, Tray, Icon, %icon% ; Set the tray icon
If (onTop = "True")
 Gui +AlwaysOnTop -Caption -MinimizeBox -MaximizeBox ; Keep the screensaver on top of other windows
Gui, Color, %bkg%, %bkg% ; Set up the background colors

; Define the password input form
Gui, Font, s10, %fontName%
Gui, Add, Edit, x90 y90 w%formWidth% Lowercase Password ventry ; Text entry field
Gui, Add, Button, x+10 default w%formWidth%, OK ; Pressing ENTER will run subroutine "ButtonOK"

; Define the photo
If FileExist(photo)
 Gui, Add, Picture, x80 y80, %photo% ; Define the photo to be displayed

; Define the text color, user's name, e-mail address, and phone number to be displayed
Gui, Font, s%fontSize%, %fontName%
Gui, Add, Text, x+%hpad% y130 c%textColor%, %name%
Gui, Add, Text, y+%vpad% c%textColor%, %email%
Gui, Add, Text, y+%vpad% c%textColor%, Ph %phone%

; Finish
set(taskManager,disable)
MouseMove, 220, 570
Gui, Show, Maximize ; Show the screensaver using the definitions above
focus()
Return
; ============================================
ButtonOK:
Gui, Submit, NoHide ; Save the user's entry in variable "entry"
tries++
If (tries >= maxTries) AND (entry <> pwd)
{
 DllCall("LockWorkStation")
 Sleep, 3000
}
If (tries >= maxTries) OR (entry = pwd)
{
 set(taskManager,enable)
 ExitApp
}
focus()
Return
; --------------------------------------------
focus() ; Clear, and focus on, the password entry field
{
GuiControl,, entry ; Clear the password entry field
GuiControl, Focus, entry
}
; --------------------------------------------
set(tm,status)
{
If (tm = "True")
 RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System, DisableTaskMgr, %status%
}

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。