forked from mikebaldi/Idle-Champions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ICScriptHub.ahk
230 lines (205 loc) · 7.93 KB
/
ICScriptHub.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#Requires AutoHotkey 1.1.33+ <1.2
#SingleInstance force
;put together with the help from many different people. thanks for all the help.
#HotkeyInterval 1000 ; The default value is 2000 (milliseconds).
#MaxHotkeysPerInterval 70 ; The default value is 70
#NoEnv ; Avoids checking empty variables to see if they are environment variables (recommended for all new scripts). Default behavior for AutoHotkey v2.
; #Warn ALL, OutputDebug
;=======================
;Script Optimization
;=======================
SetWorkingDir %A_ScriptDir%
SetWinDelay, 33 ; Sets the delay that will occur after each windowing command, such as WinActivate. (Default is 100)
SetControlDelay, 0 ; Sets the delay that will occur after each control-modifying command. -1 for no delay, 0 for smallest possible delay. The default delay is 20.
;SetKeyDelay, 0 ; Sets the delay that will occur after each keystroke sent by Send or ControlSend. [SetKeyDelay , Delay, PressDuration, Play]
SetBatchLines, -1 ; How fast a script will run (affects CPU utilization).(Default setting is 10ms - prevent the script from using any more than 50% of an idle CPU's time.
; This allows scripts to run quickly while still maintaining a high level of cooperation with CPU sensitive tasks such as games and video capture/playback.
ListLines Off
Process, Priority,, Normal
CoordMode, Mouse, Client
;Modron Automation Gem Farming Script
GetScriptHubVersion()
{
return "v3.6.2, 2023-11-14"
}
;class and methods for parsing JSON (User details sent back from a server call)
#include %A_ScriptDir%\SharedFunctions\json.ahk
;server call functions and variables Included after GUI so chest tabs maybe non optimal way of doing it
#include %A_ScriptDir%\ServerCalls\IC_ServerCalls_Class.ahk
;logging functions
;#include *i %A_ScriptDir%\Logging\IC_Log_Class.ahk
global g_KeyMap := KeyHelper.BuildVirtualKeysMap()
global g_ServerCall
global g_UserSettings := {}
global g_TabControlHeight := 630
global g_TabControlWidth := 430
global g_InputsSent := 0
global g_TabList := ""
global g_PlayButton := A_LineFile . "\..\Images\play-100x100.png"
global g_StopButton := A_LineFile . "\..\Images\stop-100x100.png"
global g_ConnectButton := A_LineFile . "\..\Images\connect-100x100.png"
global g_ReloadButton := A_LineFile . "\..\Images\refresh-smooth-25x25.png"
global g_SaveButton := A_LineFile . "\..\Images\save-100x100.png"
global g_GameButton := A_LineFile . "\..\Images\idledragons-25x25.png"
global g_MouseTooltips := {}
global g_Miniscripts := {}
;Load themes
GUIFunctions.LoadTheme()
if (GUIfunctions.isDarkMode)
g_ReloadButton := A_LineFile . "\..\Images\refresh-smooth-white-25x25.png"
;Load user settings
g_UserSettings := IC_SharedFunctions_Class.LoadObjectFromJSON( A_LineFile . "\..\Settings.json" )
;check if first run
If !IsObject( g_UserSettings )
{
g_UserSettings := {}
g_UserSettings[ "WriteSettings" ] := true
}
if ( g_UserSettings[ "InstallPath" ] == "" )
g_UserSettings[ "InstallPath" ] := "C:\Program Files (x86)\Steam\steamapps\common\IdleChampions\IdleDragons.exe"
if (g_UserSettings[ "ExeName"] == "")
g_UserSettings[ "ExeName"] := "IdleDragons.exe"
if ( g_UserSettings[ "WindowXPosition" ] == "" )
g_UserSettings[ "WindowXPosition" ] := 0
if ( g_UserSettings[ "WindowYPosition" ] == "" )
g_UserSettings[ "WindowYPosition" ] := 0
if ( g_UserSettings[ "NoCtrlKeypress" ] == "" )
g_UserSettings[ "NoCtrlKeypress" ] := 0
if ( g_UserSettings[ "WaitForProcessTime" ] == "" )
g_UserSettings[ "WaitForProcessTime" ] := 0
if(g_UserSettings[ "WriteSettings" ] == true)
{
g_UserSettings.Delete("WriteSettings")
IC_SharedFunctions_Class.WriteObjectToJSON( A_LineFile . "\..\Settings.json" , g_UserSettings )
}
global g_SF := new IC_SharedFunctions_Class ; includes MemoryFunctions in g_SF.Memory
;define a new gui with tabs and buttons
Gui, ICScriptHub:New
Gui, ICScriptHub:+Resize -MaximizeBox
Gui, ICScriptHub: +HwndGUIICScriptHub
;Gui, ICScriptHub:Add, Button, x4 y5 w50 gReload_Clicked, `Reload
;Gui, ICScriptHub:Add, Button, x+20 gLaunch_Clicked, Launch IC
global g_MenuBarXPos:=4
GUIFunctions.AddButton(g_GameButton,"Launch_Clicked","LaunchClickButton")
GUIFunctions.AddButton(g_ReloadButton,"Reload_Clicked","ReloadClickButton")
GUIFunctions.UseThemeTextColor()
; Needed to add tabs
Gui, ICScriptHub:Add, Tab3, x5 y32 w%g_TabControlWidth%+40 h%g_TabControlHeight%+40 vModronTabControl, %g_TabList%
; Set specific tab ordering for prioritized scripts.
GuiControl, Move, ICScriptHub:ModronTabControl, % "w" . g_TabControlWidth . " h" . g_TabControlHeight
GUIFunctions.UseThemeBackgroundColor()
Gui, ICScriptHub:Show, % "x" . g_UserSettings[ "WindowXPosition" ] " y" . g_UserSettings[ "WindowYPosition" ] . " w" . g_TabControlWidth+5 . " h" . g_TabControlHeight, % "IC Script Hub" . (g_UserSettings[ "WindowTitle" ] ? (" - " . g_UserSettings[ "WindowTitle" ]) : "") . " (Loading...)"
GUIFunctions.UseThemeTitleBar("ICScriptHub")
;WinSet, Style, -0xC00000, A ; Remove the active window's title bar (WS_CAPTION).
Reload_Clicked()
{
Reload
return
}
Launch_Clicked()
{
programLoc := g_UserSettings[ "InstallPath" ]
try
{
Run, %programLoc%
}
catch
{
MsgBox, 48, Unable to launch game, `nVerify the game location is set properly by enabling the Game Location Settings addon, clicking Change Game Location on the Briv Gem Farm tab, and ensuring the launch command is set properly.
}
Process, Exist, % g_UserSettings[ "ExeName"]
g_SF.PID := ErrorLevel
}
ICScriptHubGuiClose()
{
MsgBox 4,, Are you sure you want to `exit?
IfMsgBox Yes
{
MiniScriptWarning()
ExitApp
}
IfMsgBox No
return True
}
ICScriptHubGuiSize(GuiHwnd, EventInfo, Width, Height)
{
GuiControl, Move, ModronTabControl, % "w" Width - 20 "h" Height - 40
GuiControl, Move, MemoryFunctionsViewID, % "w" Width - 40 "h" Height - 120
GuiControl, Move, InventoryViewID, % "w" Width - 40 "h" Height - 170
}
; ToolTip Test
OnMessage(0x200, "CheckControlForTooltip")
; Creates tooltips for various controls in Script Hub.
BuildToolTips()
{
GUIFunctions.AddToolTip("LaunchClickButton", "Launch Idle Champions")
GUIFunctions.AddToolTip("ReloadClickButton", "Reload Script Hub")
}
; Shows a tooltip if the control with mouseover has a tooltip associated with it.
CheckControlForTooltip()
{
MouseGetPos,,,VarWin, VarControl
varTTLoc := VarWin . VarControl
if(varTTLoc)
ToolTip % g_MouseToolTips[varTTLoc]
else
ToolTip
SetTimer, HideToolTip, -3000
}
HideToolTip()
{
ToolTip
}
;#include %A_ScriptDir%\SharedFunctions\Windrag.ahk
; Shared Functions
#include %A_ScriptDir%\SharedFunctions\IC_SharedFunctions_Class.ahk
#include %A_ScriptDir%\SharedFunctions\IC_ArrayFunctions_Class.ahk
#include %A_ScriptDir%\SharedFunctions\IC_KeyHelper_Class.ahk
#include %A_ScriptDir%\SharedFunctions\IC_GUIFunctions_Class.ahk
#include %A_ScriptDir%\SharedFunctions\IC_UpdateClass_Class.ahk
#include *i %A_ScriptDir%\AddOns\AddOnsIncluded.ahk
;#IfWinActive ahk_exe AutoHotkeyU64.exe
;!LButton::WindowMouseDragMove()
;^LButton::WindowMouseDragMove()
BuildToolTips()
if(IsObject(AddonManagement))
AddonManagement.BuildToolTips()
Gui, ICScriptHub:Show,, % "IC Script Hub" . (g_UserSettings[ "WindowTitle" ] ? (" - " . g_UserSettings[ "WindowTitle" ]) : "")
StopMiniscripts()
{
for k,v in g_Miniscripts
{
try
{
SharedRunData := ComObjActive(k)
SharedRunData.Close()
}
}
}
CountRunningMiniscripts()
{
objectCount := 0
for k,v in g_Miniscripts
{
try
{
SharedRunData := ComObjActive(k)
objectCount += 1
}
}
return objectCount
}
MiniScriptWarning()
{
if(CountRunningMiniscripts())
{
MsgBox 4,, There are still Miniscripts running in the baackground. Do you wish to close them?
IfMsgBox Yes
{
StopMiniscripts()
ExitApp
}
IfMsgBox No
return True
}
}