-
Notifications
You must be signed in to change notification settings - Fork 1
/
fass.ahk
206 lines (161 loc) · 5.31 KB
/
fass.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
;@Ahk2Exe-SetMainIcon fass.ico
global AppVersion := "0.3.1"
global IniPath := "settings.ini"
;;; CHOOSE ACCOUNT
; Reads the account list from the settings file and generates a ListBox
; compatible string with account usernames.
GetAccountList() {
IniRead, UseAlias, %IniPath%, General, UseAlias
if (UseAlias == "true") {
IniRead, RawAccounts, %IniPath%, Alias
} else {
IniRead, RawAccounts, %IniPath%, Accounts
}
Accounts := StrSplit(Trim(RawAccounts, OmitChars = " `t`n"), "`n")
Listing :=
for Index, Account in Accounts {
Username := StrSplit(Account, "=")[1]
Listing = %Listing%%Username%
if (Index != Accounts.MaxIndex()) {
Listing = %Listing%|
}
}
return Listing
}
Gui, Main:New,, Choose Account
Listing := GetAccountList()
Gui, Main:Add, ListBox, r10 w240 vAccountUsername gLaunchViaList, %Listing%
Gui, Main:Add, Button, w240 gAddAccount, Add Account
Gui, Main:Add, Button, w240 gRemoveAccount, Remove Account
Gui, Main:Add, Button, w240 gExitButton, Exit
Gui, Main:Add, StatusBar,, LoL-FASS v%AppVersion% with ♥ by C0Nd3Mnd
Gui, Main:Show
return
GuiEscape:
GuiClose:
ExitButton:
ExitApp, 0
AddAccount:
Gui, AddAccount:New,, Add Account
Gui, AddAccount:Add, Text,, Username
Gui, AddAccount:Add, Edit, w240 vNewUsername
Gui, AddAccount:Add, Text,, Password
Gui, AddAccount:Add, Edit, Password w240 vNewPassword
Gui, AddAccount:Add, Button, w240 gConfirmAddAccount, Add
Gui, AddAccount:Add, Button, w240 gCancel, Cancel
Gui, AddAccount:Add, Text, cGray w240, Note that if you enter a username that already exists, its password will be changed instead.
Gui, AddAccount:Show
return
ReloadAccountList() {
Listing := GetAccountList()
GuiControl, Main:, AccountUsername, |%Listing%
}
ConfirmAddAccount:
Gui, AddAccount:Submit, NoHide
if (NewUsername == "") {
MsgBox, Username cannot be empty!
return
}
if (NewPassword == "") {
MsgBox, Password cannot be empty!
return
}
IniWrite, %NewPassword%, %IniPath%, Accounts, %NewUsername%
Gui, AddAccount:Hide
ReloadAccountList()
return
RemoveAccount(AccountUsername) {
IniDelete, %IniPath%, Accounts, %AccountUsername%
ReloadAccountList()
}
RemoveAccount:
Gui, Main:Submit, NoHide
MsgBox, 4, Remove account?, Remove account "%AccountUsername%"?
IfMsgBox Yes
RemoveAccount(AccountUsername)
return
LaunchViaList:
if (A_GuiEvent == "DoubleClick") {
Gui, Main:Submit
Goto, Main
}
return
Main:
IniRead, UseAlias, %IniPath%, General, UseAlias
if (UseAlias == "true") {
IniRead, AccountUsername, %IniPath%, Alias, %AccountUsername%
}
IniRead, AccountPassword, %IniPath%, Accounts, %AccountUsername%
if WinExist("ahk_exe LeagueClientUx.exe") {
WinGetPos, ,, ClientWidth, ClientHeight, ahk_exe LeagueClientUx.exe
CloseButtonX := ClientWidth * 0.9849
CloseButtonY := ClientHeight * 0.0203
; Can be an exit button...
ExitButtonX := ClientWidth * 0.4557
ExitButtonY := ClientHeight * 0.5574
; ...or a Yes button.
YesButtonX := ClientWidth * 0.4739
YesButtonY := ClientHeight * 0.6018
ControlClick, x%CloseButtonX% y%CloseButtonY%, ahk_exe LeagueClientUx.exe
; Delay for a bit since the client can be slow to open the window sometimes.
Sleep, 500
; Click the Yes button first because if the Exit button is the correct one
; the other click sometimes still goes through before the client exits
; potentially resulting in a click on the start page of the client which
; opens up a website in a browser.
ControlClick, x%YesButtonX% y%YesButtonY%, ahk_exe LeagueClientUx.exe
ControlClick, x%ExitButtonX% y%ExitButtonY%, ahk_exe LeagueClientUx.exe
;; Delay a bit so the dodge works more reliably.
Sleep, 1000
}
;;; KILL ALL (DEAD) PROCESSES
Process, Close, RiotClientCrashHandler.exe
Process, Close, RiotClientServices.exe
Process, Close, LeagueClient.exe
Process, Close, LeagueClientUx.exe
Process, WaitClose, RiotClientCrashHandler.exe
Process, WaitClose, RiotClientServices.exe
Process, WaitClose, LeagueClient.exe
Process, WaitClose, LeagueClientUx.exe
;;; RIOT CLIENT
IniRead, RiotPath, %IniPath%, General, RiotPath
Run, "%RiotPath%\Riot Client\RiotClientServices.exe" --launch-product=league_of_legends --launch-patchline=live
Loop {
if WinExist("Riot Client Main") {
Sleep, 1000
Break
}
Sleep, 1000
}
WinGetPos, ,, LauncherWidth, LauncherHeight, Riot Client Main
Sleep, 1000
; Username
UsernameInputX := LauncherWidth * 0.13
UsernameInputY := LauncherHeight * 0.3
ControlClick, x%UsernameInputX% y%UsernameInputY%, Riot Client Main
Send, {Text}%AccountUsername%
; Password
Send, {Tab}
Send, {Text}%AccountPassword%
; Login button
Send, {Enter}
; Show skip window to exit early.
SkipPosX := A_ScreenWidth - 300
SkipPosY := A_ScreenHeight - 140
Gui, Skip:New,, Update Skip
Gui, Skip:Add, Button, w240 gExit, Exit Early (Update Skip)
Gui, Skip:Show, x%SkipPosX% y%SkipPosY%
; Press play if the window still exists (sometimes it doesn't launch
; automatically).
Loop {
Sleep, 5000
if WinExist("Riot Client Main") {
PlayButtonX := LauncherWidth * 0.1302
PlayButtonY := LauncherHeight * 0.3472
ControlClick, x%PlayButtonX% y%PlayButtonY%, Riot Client Main
} else {
break
}
}
Exit:
ExitApp, 0