-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlock.ahk
62 lines (45 loc) · 1.06 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <log4ahk.ahk>
; Initialize the logger
logger := new log4ahk()
; Set the appenders to be logged to: STDOUT
logger.appenders.push(new logger.appenderstdout())
;#x::ExitApp ; Assign a hotkey to terminate this script.
MsgBox % KeyWaitAny()
; Same again, but don't block the key.
MsgBox % KeyWaitAny("V")
KeyWaitAny(Options:="")
{
ih := InputHook(Options)
ih.KeyOpt("{All}", "ES") ; End and Suppress
ih.Start()
ErrorLevel := ih.Wait() ; Store EndReason in ErrorLevel
DllCall("LockWorkStation")
ExitApp
return ih.EndKey ; Return the key name
}
MouseGetPos, StartVarX, StartVarY
loop
{
sleep, 100
MouseGetPos, CheckVarX, CheckVarY
If (StartVarX != CheckVarX) or (StartVarY != CheckVarY)
{
DllCall("LockWorkStation")
ExitApp
}
}
#Persistent
SetTimer,Timer,300
Return
Timer:
MouseGetPos,x1,y1
Sleep,500
MouseGetPos,x2,y2
If ((x1<>x2) or (y1<>y2)) ;-- Checking to see if the mouse has moved.
{
DllCall("LockWorkStation")
ExitApp
Return
}
return
esc::exitapp