#Persistent #SingleInstance Force ;====================================配置=========== file = %A_ScriptDir%lock.jpg ;锁屏图片 key = app ;密码 hotkey = ^`` ;快捷键 idle = 10 ;鼠键空闲多少分钟后自动锁定 direct_lock = 0 ;运行软件时立即锁定 if_turnoff_monitor = 1 ;锁定时自动关闭屏幕 ;==================================================== Menu, tray, NoStandard Menu, tray, DeleteAll Menu, tray, Add, 锁定, start Menu, tray, Default, 锁定 Menu, tray, Add Menu, tray, Add, 退出, exitit Hotkey, %hotkey%, start, On gosub CheckIdle if !direct_lock return start: SetTimer, CheckIdle, Off MouseGetPos, x, y MouseMove, A_ScreenWidth+10, A_ScreenHeight+10, 0 BlockInput, MouseMove if if_turnoff_monitor ;关闭屏幕 gosub TurnoffMonitor ;间隔5秒检查屏幕是否黑屏 key_list = Lbutton,Rbutton,Mbutton,LWin,Rwin,LAlt,RAlt,Ctrl,esc,del,f1,f4,tab Loop, parse, key_list, `, Hotkey, % A_LoopField, stop, on IfExist, %file% ;显示图片 { Gui, +AlwaysOnTop +Disabled -SysMenu +Owner -Caption +ToolWindow Gui, margin, 0,0 Gui, Add, Picture, w%A_ScreenWidth% h%A_ScreenHeight%, %file% Gui, Show, Maximize } i = 1 Loop { Input, a, L1 i := (a = substr(key,i,1)) ? i+1 : 1 if (i=(strlen(key)+1)) { if if_turnoff_monitor SetTimer, TurnoffMonitor, off ;关闭间隔3秒检查屏幕是否黑屏 BlockInput, MouseMoveOff MouseMove, x, y, 0 Loop, parse, key_list, `, Hotkey, % A_LoopField, stop, off SetTimer, CheckIdle, On IfExist, %file% Gui, Destroy return } } return CheckIdle: if idle SetTimer,CheckIdle,% idle*60000-A_TimeIdle if (A_TimeIdle >= idle*60000 and idle > 0) Gosub start return TurnoffMonitor: SetTimer, TurnoffMonitor, % A_TimeIdle>9000 ? 5000 : 5000-A_TimeIdle ;间隔5秒检查屏幕是否黑屏 if (A_TimeIdle > 5000 and A_TimeIdle < 9000) SendMessage, 0x112, 0xF170, 2,,ahk_id 0xFFFF ;关闭屏幕 return stop: return exitit: ExitApp