-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutoSaver.ahk
100 lines (83 loc) · 1.96 KB
/
AutoSaver.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#Requires AutoHotkey v2.0
global SoundPlayed := false
SaveIntervalMinutes := 10
if !(WinExist("ahk_exe bg3.exe") or WinExist("ahk_exe bg3_dx11.exe")) {
Run "bg3.lnk"
}
Sleep 10000
SetTimer(CheckGameStart, 1000)
SetTimer(CheckGameClosed, 1000)
CheckGameStart() {
if (CheckGame()) {
; Debug ToolTip
;ToolTip "CheckGame returned: true"
;Sleep 1000
;ToolTip
SetTimer(PressTheKey, SaveIntervalMinutes * 60000)
SetTimer(CheckGameStart, 0)
}
return
}
CheckGame() {
global SoundPlayed
if (WinActive("ahk_exe bg3.exe") or WinActive("ahk_exe bg3_dx11.exe")) {
; Debug ToolTip
;ToolTip "CheckGame returned: true"
;Sleep 1000
;ToolTip
if(!(SoundPlayed)){
SoundPlay("infocus.mp3")
SoundPlayed := true
}
return true
}
; Debug ToolTip
;ToolTip "CheckGame returned: false"
;Sleep 1000
;ToolTip
if(SoundPlayed){
SoundPlay("*16")
SoundPlayed := false
}
return false
}
CheckGameClosed() {
if !(WinExist("ahk_exe bg3.exe") or WinExist("ahk_exe bg3_dx11.exe")) {
; Debug ToolTip
;ToolTip "CheckGameClosed returned: true"
;Sleep 1000
;ToolTip
SoundPlay("*16")
SetTimer(CheckGameStart, 0)
SetTimer(PressTheKey, 0)
ExitApp
}
}
CheckAFK() {
global SoundPlayed
idleTime := A_TimeIdlePhysical
if (idleTime > 60000) {
; Debug ToolTip
;ToolTip "CheckAFK returned: true"
;Sleep 1000
;ToolTip
if(SoundPlayed){
SoundPlay("*16")
SoundPlayed := false
}
SetTimer(CheckGameStart, 0)
SetTimer(PressTheKey, 0)
return true
}
; Debug ToolTip
;ToolTip "CheckAFK returned: false"
;Sleep 1000
;ToolTip
return false
}
PressTheKey() {
If (CheckGame() and !CheckAFK()) {
Send("{F5}")
}
}
return