/ Published in: AutoIt
This is a AutoHotKey.com script. It runs on Windows and allows you to lock your computer by simply hitting a single key combination and unlock it with a different one. Download the whole script at the url listed.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
; Program: LockScreen utility ; Author: Dean Householder ; Website: http://www.deanhouseholder.com/ ; Version: 1.3 9/28/2012 ; Copyright: GPL #SingleInstance, Force #Persistent IniPath = %A_WorkingDir%\LockScreen.ini If !A_IsCompiled Menu, Tray, Icon, %A_ScriptDir%\LockScreen.ico Menu, Tray, Icon, %A_ScriptName% IfNotExist, %IniPath% { FileAppend, , %IniPath%, CP0 } Hotkey, %LockHotkeyStart%, StartLock, UseErrorLevel Hotkey, %LockHotkeyEnd%, EndLock, UseErrorLevel ~ESC:: Reload StartLock: IfWinNotExist, BlackScreen1 ahk_class AutoHotkeyGUI { SetFormat Integer, Dec SysGet, Monitors, MonitorCount ; Count monitors Loop, %Monitors% ; Loop through each monitor { SysGet, Mon%A_Index%, Monitor, %A_Index% ; Get this monitor's stats Height := Mon%A_Index%Bottom - Mon%A_Index%Top ;MsgBox, % "Left: " Mon%A_Index%Left " | Top: " Mon%A_Index%Top " | Right: " Mon%A_Index%Right " | Bottom: " Mon%A_Index%Bottom "`n" Width "x" Height ; Create a large black window to cover all other windows for each monitor Gui %A_Index%: -Caption +ToolWindow +AlwaysOnTop Gui %A_Index%: Color, Black Gui %A_Index%: Font, s36 c555555 Gui %A_Index%: Add, Text, % "x" Width//2-85 " y" Height//2-80, Locked Gui %A_Index%: Show, % "x" Mon%A_Index%Left " y" Mon%A_Index%Top " w" Width " h" Height Hide, BlackScreen%A_Index% Gui %A_Index%: Show } { { ;SendMessage, 0x112, 0xF140, 0,, Program Manager ; 0x112 is WM_SYSCOMMAND -- 0xF140 is SC_SCREENSAVE } } { SetFormat Integer, Hex Loop 255 ; Loop through every character { Hotkey % "*vk" SubStr(A_Index+256,4), TurnOffScreen ; Set a hotkey for each character to turn off screen--very annoying } } } EndLock: IfWinExist BlackScreen1 ahk_class AutoHotkeyGUI { KeyWait, %LockHotkeyEnd%, T%UnlockDuration% ; Expect the end Lockkey to be pressed for one second If ErrorLevel { SetFormat Integer, Dec SysGet, Monitors, MonitorCount ; Count monitors again in case it changed while locked Loop, %Monitors% { Gui %A_Index%: Destroy ; Kill previous black screen GUI's } SetFormat Integer, Hex Loop 255 ; Loop through every character { Hotkey % "*vk" SubStr(A_Index+256,4), Off } Reload } } TurnOffScreen: SendMessage, 0x112, 0xF170, 2,, Program Manager ; Turn off the monitor(s)
URL: http://www.deanhouseholder.com/projects/lockscreen/