-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlock.ahk
35 lines (32 loc) · 1.65 KB
/
lock.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
This idea of storing settings in the script itself is stolen from emmanuel d
http://www.autohotkey.com/community/viewtopic.php?f=2&t=75381
[Settings] ; The script doesn't see this line. The ini sees a new section heading.
*/
PassChar = z ; Use any character you like
PassWrd = 1453 ; Same for password
/*
[EndSettings] ; The ini sees the lines above as keys and values. The script sees values assigned to variables.
*/
F12:: ; Lock everything
; **************************************************************
; *** A single press of PassChar immediately unlocks computer ***
; *** Any other key pressed requires full password ***
; **************************************************************
; WinMinimizeAll ; Hide what's on screen
Hotkey !Tab, NULL ; Disable alt-tab
BlockInput, MouseMove ; Disable mousemoves
Input, SingleKey, L1 ; Wait for user to type something.
If (SingleKey <> PassChar) ; PassChar?
{ ; No, so demand full password
String :=
While String <> PassWrd
InputBox String, Computer is locked!, Password:, HIDE, 250, 150
}
; SoundPlay c:\Windows\Media\B6.WAV ; Play sound to announce computer successfully unlocked
Hotkey !Tab, Off ; Restore alt-tab
BlockInput MouseMoveOff ; Restore mouse moves
; WinMinimizeAllUndo ; Restore screen
Return
NULL: ; Dummy routine for alt-tab (does nothing)
Return