-
Notifications
You must be signed in to change notification settings - Fork 0
/
HDT Import.ahk
609 lines (508 loc) · 12.2 KB
/
HDT Import.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
CoordMode, Mouse, Window
;#SingleInstance Ignore
;Gui
GUI:
Gui, Add, Text, x20 y10, Modes To Import:
Gui, Add, CheckBox, viranked checked x40 yp+30, Ranked
Gui, Add, CheckBox, vicasual xp+105, Casual
Gui, Add, CheckBox, viarena x40, Arena
Gui, Add, CheckBox, vibrawl xp+105, Brawl
Gui, Add, CheckBox, vifriendly x40, Friendly
Gui, Add, CheckBox, vipractice xp+105, Practice
Gui, Add, Text, x20 yp+30, Note:
Gui, Add, Edit, vnote w200, Entered by HDT Import
Gui, Add, Button, yp+40 x20 w200, Import
Gui, Add, Button, yp+30 x20 w200, Exit
Gui, Show, w240, HDT Import
Return
ButtonExit:
exitapp
ButtonImport:
Gui, Submit
currentgame := {class: "", oclass: "", opponent: "", result: "", mode: "", rank: "", turns: "", duration: ""}
lastclass := ""
;GamesHistory and recording games already in HDT
gameshistory := ""
Loop, Read, %A_AppData%\HearthstoneDeckTracker\DeckStats.xml
{
;A_LoopReadLine
If InStr(A_LoopReadLine, "<PlayerHero>")
{
ReplacedStr := StrReplace(A_LoopReadLine, "<PlayerHero>")
ReplacedStr := StrReplace(ReplacedStr, "</PlayerHero>")
currentgame["class"] := Trim(ReplacedStr, " `t")
}
Else If InStr(A_LoopReadLine, "<OpponentHero>")
{
ReplacedStr := StrReplace(A_LoopReadLine, "<OpponentHero>")
ReplacedStr := StrReplace(ReplacedStr, "</OpponentHero>")
currentgame["oclass"] := Trim(ReplacedStr, " `t")
}
Else If InStr(A_LoopReadLine, "<GameMode>")
{
ReplacedStr := StrReplace(A_LoopReadLine, "<GameMode>")
ReplacedStr := StrReplace(ReplacedStr, "</GameMode>")
If !InStr(ReplacedStr, "Ranked")
currentgame["rank"] := ""
currentgame["mode"] := Trim(ReplacedStr, " `t")
}
Else If InStr(A_LoopReadLine, "<Result>")
{
ReplacedStr := StrReplace(A_LoopReadLine, "<Result>")
ReplacedStr := StrReplace(ReplacedStr, "</Result>")
If InStr(ReplacedStr, "Win")
currentgame["result"] := "Won"
Else If InStr(ReplacedStr, "Loss")
currentgame["result"] := "Lost"
Else
currentgame["result"] := Trim(ReplacedStr, " `t")
}
Else If InStr(A_LoopReadLine, "<Turns>")
{
ReplacedStr := StrReplace(A_LoopReadLine, "<Turns>")
ReplacedStr := StrReplace(ReplacedStr, "</Turns>")
currentgame["turns"] := Trim(ReplacedStr, " `t")
}
Else If InStr(A_LoopReadLine, "<OpponentName>")
{
ReplacedStr := StrReplace(A_LoopReadLine, "<OpponentName>")
ReplacedStr := StrReplace(ReplacedStr, "</OpponentName>")
ReplacedStrArray := StrSplit(ReplacedStr, "#")
currentgame["opponent"] := Trim(ReplacedStrArray.1, " `t")
}
Else If InStr(A_LoopReadLine, "<Rank>")
{
ReplacedStr := StrReplace(A_LoopReadLine, "<Rank>")
ReplacedStr := StrReplace(ReplacedStr, "</Rank>")
currentgame["rank"] := Trim(ReplacedStr, " `t")
}
Else If InStr(A_LoopReadLine, "<StartTime>")
{
starttime := Trim(A_LoopReadLine, " `t")
startdate := SubStr(starttime, 12, 10)
startdatearray := StrSplit(startdate, "-")
starttime := SubStr(starttime, 23, 8)
starttimearray := StrSplit(starttime, ":")
starttime := startdatearray[1].=startdatearray[2].=startdatearray[3].=starttimearray[1].=starttimearray[2].=starttimearray[3]
}
Else If InStr(A_LoopReadLine, "<EndTime>")
{
endtime := Trim(A_LoopReadLine, " `t")
enddate := SubStr(endtime, 10, 10)
enddatearray := StrSplit(enddate, "-")
endtime := SubStr(endtime, 21, 8)
endtimearray := StrSplit(endtime, ":")
endtime := enddatearray[1].=enddatearray[2].=enddatearray[3].=endtimearray[1].=endtimearray[2].=endtimearray[3]
endtime -= starttime, m
currentgame["duration"] := endtime
}
Else If InStr(A_LoopReadLine, "</Game>")
{
cg := ""
For k, v in currentgame
{
If k != duration
cg .= v "|"
}
If InStr(gameshistory, cg)
Continue
Else
gameshistory .= cg "`n"
}
Else If InStr(A_LoopReadLine, "</DeckStatsList>")
Break
}
myreplayscheck:
IfWinNotExist, My Replays - HSReplay.net - Google Chrome
{
MsgBox, 1, ,Please open My Replays on HSReplay.net`nand display in list view.
IfMsgBox OK
{
Goto, myreplayscheck
}
else IfMsgBox Cancel
{
return
}
}
WinRestore, My Replays - HSReplay.net - Google Chrome
WinMove, My Replays - HSReplay.net - Google Chrome, , 0, 0, 1936, 1096
winreplayscheck:
IfWinNotExist, Hearthstone Deck Tracker
{
MsgBox, 1, , Please open Hearthstone Deck Tracker
IfMsgBox OK
{
Sleep, 5000
Goto, winreplayscheck
}
else IfMsgBox Cancel
{
return
}
}
WinActivate, Hearthstone Deck Tracker
WinWaitActive, Hearthstone Deck Tracker
WinRestore, Hearthstone Deck Tracker
WinMove, Hearthstone Deck Tracker, , , , 1469, 814
/*
ImageSearch, hdtx, hdty, 34, 43, 176, 208, *TransWhite *n2 hdtd.bmp
If ErrorLevel >=1
ImageSearch, hdtx, hdty, 34, 43, 176, 208, *TransWhite *n2 hdtd2.bmp
If ErrorLevel >=1
{
MsgBox, ImageSearch Error`nHDT Import will exit
exitapp
}
*/
hdtx := 130
hdty := 184
hdtally := hdty-44
mouseclick, left, 67, %hdtally%
IfWinNotExist, Stats
{
WinActivate, Hearthstone Deck Tracker
WinWaitActive, Hearthstone Deck Tracker
Click, 320, 46
Sleep, 250
;Click, 346, 104
Send {Down 2}{Enter}
Sleep, 500
IfWinNotExist, Stats
Click, 76, 75
Sleep, 250
WinRestore, Stats
WinActivate, Stats
WinWaitActive, Stats
Send {down}
;Click 66, 232
Sleep, 250
}
WinRestore, Stats
WinMove, Stats, , , , 829, 672
getgames:
WinActivate, My Replays - HSReplay.net - Google Chrome
WinWaitActive, My Replays - HSReplay.net - Google Chrome
clipboard := ""
send ^a
sleep, 250
send ^c
clipwait, 1
parseready := ""
Loop, Parse, clipboard, `n
{
If parseready = 1
Goto ParseGames
If A_LoopField contains MATCH OPPONENT RESULT MODE DURATION TURNS PLAYED
parseready := 1
continue
ParseGames:
If A_LoopField contains PreviousNext
Break
Else If A_LoopField contains HSReplay HSReplay.net
Break
++gameline
If gameline = 1
{
Loop, parse, A_LoopField, %A_Tab%
{
If A_Index = 2
currentgame["Class"] := A_LoopField
Else If A_Index = 5
currentgame["oclass"] := A_LoopField
Else If A_Index = 7
currentgame["opponent"] := A_LoopField
Else If A_Index = 8
currentgame["result"] := A_LoopField
}
Continue
}
Else If gameline = 2
{
Loop, parse, A_LoopField, %A_Space%
{
If A_Index = 1
currentgame["mode"] := Trim(A_LoopField,"`r")
If currentgame["mode"] = "Adventure"
currentgame["mode"] := "Practice"
Else If currentgame["mode"] = "Tavern"
currentgame["mode"] := "Brawl"
}
Continue
}
Else If gameline = 3
{
Loop, parse, A_LoopField, %A_Space%
{
If A_Index = 1
{
If A_LoopField is integer
{
currentgame["rank"] := "25"
goto ParseGames
}
else
Continue
}
If A_Index = 2
currentgame["rank"] := Trim(A_LoopField,"`r")
}
If currentgame["mode"] != "Ranked"
currentgame["rank"] := ""
Continue
}
Else If gameline = 4
{
Loop, parse, A_LoopField, %A_Tab%
{
If A_Index = 1
currentgame["duration"] := Trim(A_LoopField, " minutesseconds")
Else If A_Index = 2
currentgame["turns"] := A_LoopField
gameline := ""
}
}
cg := ""
For k, v in currentgame
{
If k != duration
cg .= v "|"
}
If InStr(gameshistory, cg)
Continue
; viranked
; vicasual
; viarena
; vibrawl
; vifriendly
; vipractice
If currentgame["mode"] = "Ranked" and iranked = 0
Continue
Else If currentgame["mode"] = "Casual" and icasual = 0
Continue
Else If currentgame["mode"] = "Arena" and iarena = 0
Continue
Else If currentgame["mode"] = "Brawl" and ibrawl = 0
Continue
Else If currentgame["mode"] = "Friendly" and ifriendly = 0
Continue
Else If currentgame["mode"] = "Practice" and ipractice = 0
Continue
gameshistory .= cg "`n"
;enter games
;use function
hdtyuse := hdty+66
use()
{
global
mouseclick, left, 815, %hdtyuse%
}
sleep, 250
If currentgame["class"] != lastclass
{
lastclass := currentgame["class"]
WinActivate, Hearthstone Deck Tracker
WinWaitActive, Hearthstone Deck Tracker
If InStr(currentgame["class"], "Druid")
{
mouseclick, left, 131, %hdty%
use()
}
else If InStr(currentgame["class"], "Hunter")
{
mouseclick, left, 213, %hdty%
use()
}
else If InStr(currentgame["class"], "Mage")
{
mouseclick, left, 297, %hdty%
use()
}
else If InStr(currentgame["class"], "Paladin")
{
mouseclick, left, 378, %hdty%
use()
}
else If InStr(currentgame["class"], "Priest")
{
mouseclick, left, 463, %hdty%
use()
}
else If InStr(currentgame["class"], "Rogue")
{
mouseclick, left, 543, %hdty%
use()
}
else If InStr(currentgame["class"], "Shaman")
{
mouseclick, left, 628, %hdty%
use()
}
else If InStr(currentgame["class"], "Warlock")
{
mouseclick, left, 713, %hdty%
use()
}
else If InStr(currentgame["class"], "Warrior")
{
mouseclick, left, 793, %hdty%
use()
}
sleep, 250
}
WinActivate, Stats
WinWaitActive, Stats
;Click "ADD NEW GAME TO ACTIVE DECK"
click, 292, 643
sleep, 500
If !InStr(currentgame["result"], "Won")
{
sleep, 250
;Result
Click, 449, 148
sleep, 250
If InStr(currentgame["result"], "Lost")
Send {l}{Enter}
Else If InStr(currentgame["result"], "Draw")
Send {d}{Enter}
sleep, 250
}
If !InStr(currentgame["oclass"], "Druid")
{
Sleep, 250
;VS
Click, 441, 177
sleep, 250
If InStr(currentgame["oclass"], "Hunter")
Send {h}
else If InStr(currentgame["oclass"], "Mage")
Send {m}
else If InStr(currentgame["oclass"], "Paladin")
Send {p}
else If InStr(currentgame["oclass"], "Priest")
Send {p 2}
else If InStr(currentgame["oclass"], "Rogue")
Send {r}
else If InStr(currentgame["oclass"], "Shaman")
Send {s}
else If InStr(currentgame["oclass"], "Warlock")
Send {w}
else If InStr(currentgame["oclass"], "Warrior")
Send {w 2}
Send {enter}
sleep, 250
}
If !InStr(currentgame["mode"], "Ranked")
{
mm := 2
sleep, 250
;Mode
Click, 434, 203
sleep, 250
If InStr(currentgame["mode"], "Casual")
{
Send {c}{Enter}
mm := 3
}
else If InStr(currentgame["mode"], "Arena")
Send {a}{Enter}
else If InStr(currentgame["mode"], "Brawl")
Send {b}{Enter}
else If InStr(currentgame["mode"], "Friendly")
Send {f}{Enter}
else If InStr(currentgame["mode"], "Practice")
Send {p}{Enter}
sleep, 250
}
else
{
r := currentgame["rank"]
mm := 1
sleep, 250
;Mode
Click, 434, 203
sleep, 250
send {r}{enter}
;Rank
Click, 381, 287, 2
send, %r%
sleep, 250
}
t := currentgame["turns"]
op := currentgame["opponent"]
d := currentgame["duration"]
If mm = 1 ;Ranked
{
;Turns
click, 388, 399, 2
send, %t%
sleep, 250
;Duration
click, 388, 427, 2
send, %d%
sleep, 250
;Opponent
click, 398, 483
send, %op%
sleep, 250
;Note
click, 400, 454
send, %note%
sleep, 250
;add game
click, 345, 568
sleep, 250
}
else If mm = 2 ;Arena, Brawl, Friendly, Practice
{
;Turns
click, 388, 315, 2
send, %t%
sleep, 250
;Duration
click, 388, 342, 2
send, %d%
sleep, 250
;Opponent
click, 402, 399
send, %op%
sleep, 250
;Note
click, 389, 370
send, %note%
sleep, 250
;add game
click, 344, 484
sleep, 250
}
else If mm = 3 ;Casual
{
;Turns
click, 388, 343, 2
send, %t%
sleep, 250
;Duration
click, 388, 371, 2
send, %d%
sleep, 250
;Opponent
click, 391, 428
send, %op%
sleep, 250
;Note
click, 398, 399
send, %note%
sleep, 250
;add game
click, 345, 514
sleep, 250
}
}
msgbox, Done.
gui, show
Esc::
exitapp