-
Notifications
You must be signed in to change notification settings - Fork 0
/
Not-AFK.ahk
53 lines (46 loc) · 1.73 KB
/
Not-AFK.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
; --------------------------------------------
; @Author : Matthieu GOSSET -
; @Contact : matthieu.gosset.dev@outlook.com -
; @Date : 1 Jan 2022 -
; @Purpose : Never be afk -
; @Credit : Random dev from StackOverflow -
; --------------------------------------------
I_Icon = assets\SleepZZZ.png
IfExist, %I_Icon%
Menu, Tray, Icon, %I_Icon%
;return
#SingleInstance force
#Persistent
settimer, idleCheck, 1000
CoordMode, Mouse, Screen
; ----------------- DEFINE ----------------- -
; Time between every input if no other input has been detected
idleTimeCheck := 30000
; You can change the key sequence to adapt it to whatever your bindings are,
; It should be a space separated list of keys to send, to send an actual space use {space}
keySequence := "w a s d"
anyKeys := StrSplit(keySequence, A_space)
; If you dont want the character to move,
; you may indicate what is the actual oposite movement key from your bindings
; ie : if 'z' is sent, your character will go forward, an 's' for backward is also sent
keySequenceOpposite := { w: "s", s: "w", a: "d", d: "a" }
return
; ----------------------------------------- -
; ----------------- MAIN ------------------ -
idleCheck:
if (A_TimeIdle >= idleTimeCheck) {
sleep, rand(0, 1000)
randomKey := anyKeys[rand(anyKeys.MinIndex(), anyKeys.MaxIndex())]
send, % randomKey (keySequenceOpposite.HasKey(randomKey) ? keySequenceOpposite[randomKey] : "")
MouseGetPos, x, y
if (x = A_ScreenWidth/2)
MouseMove, rand(0, A_ScreenWidth) , rand(0, A_ScreenHeight/2), 3
else
MouseMove, A_ScreenWidth/2, A_ScreenHeight/2, 3
}
return
rand(l, h) {
random, r, l, h
return r
}
; ----------------------------------------- -