-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAntiLockScreen.au3
79 lines (62 loc) · 1.97 KB
/
AntiLockScreen.au3
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=icon.ico
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_Res_Description=AntiLockScreen
#AutoIt3Wrapper_Res_Fileversion=3.0.1.1
#AutoIt3Wrapper_Res_ProductName=Khieudeptrai
#AutoIt3Wrapper_Res_CompanyName=TSDV
#AutoIt3Wrapper_Res_LegalCopyright=Copyright © KhieuVM
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Misc.au3>
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3>
#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
_Singleton(@ScriptName)
Opt("TrayMenuMode", 3)
Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode.
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
Global $lock = True
; Check if the registry key is already existing, so as not to damage the user's system.
RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "AntiLockScreen")
; @error is set to non-zero when reading a registry key that doesn't exist.
If @error Then
; Write a single REG_SZ value.
Local $sfilePath
$sfilePath = @ScriptDir & "\" & @ScriptName
RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run", "AntiLockScreen", "REG_SZ", $sfilePath)
EndIf
Local $idAbout = TrayCreateItem("Always on Display")
TrayItemSetOnEvent(-1, "Lock")
Local $idConfig = TrayCreateItem("Allows Lock Screen")
TrayItemSetOnEvent(-1, "Unlock")
Local $idExit = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "OnExit")
TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.
TraySetClick(16) ; Show the tray menu when the mouse if hovered over the tray icon.
TraySetToolTip("AntiLockScreen")
TraySetIcon("icon.ico")
PressLock()
Func PressLock()
While True
If @HOUR < 18 AND @HOUR > 9 Then
If $lock = True Then
Send("{SCROLLLOCK on}")
Sleep(20)
Send("{SCROLLLOCK off}")
EndIf
EndIf
Sleep(20000)
WEnd
EndFunc
Func Lock()
$lock = True
EndFunc
Func Unlock()
$lock = False
EndFunc
Func OnExit()
Exit
EndFunc