-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHWTower.au3
More file actions
124 lines (113 loc) · 3.38 KB
/
HWTower.au3
File metadata and controls
124 lines (113 loc) · 3.38 KB
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
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Misc.au3>
#include <ImageSearch.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Local $tower, $y = 0, $x = 0, $click = 0, $toweroption, $open, $chest, $proceed, $HW, $click, $done, $final
$HW = "[REGEXPTITLE:(?i)(.*Hero Wars.*)]"
Func ClickIt($xoff = 0, $yoff = 0)
MouseClick("left", $x + $xoff, $y + $yoff, 1)
$x = 0
$y = 0
EndFunc
Func MoveIt($xoff = 0, $yoff = 0)
MouseMove($x + $xoff, $y + $yoff)
$x = 0
$y = 0
EndFunc
Func ResetXY()
$x = 0
$y = 0
EndFunc
Func FindImage($imagepath, $clickyes, $skip, $seconds = 20, $xoff = 5, $yoff = 5, $tol = 80)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Parameters: $imagepath Relevant or direct path to BMP image
; $clickyes (bool) True/False to click on found image
; $skip (bool) True/False to bypass the Abort/Retry/Ignore if an image cannot be found
; $seconds (int) Number of seconds to search for the image, default is 20 seconds
; $tol (int) 0 for no tolerance (0-255), default is 80. Needed when colors of image differ from desktop. e.g GIF
; $xoff (int) X offset
; $yoff (int) Y offset
; Return Values: 0 if image not found and Ignored
; 1 if image found
; 2 if image not found and skipped
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$t = 0
ConsoleWrite("Processing " & $imagepath & @CRLF)
While 1
ToolTip($t & " of " & $seconds & " - Running - " & $imagepath, 10, 10)
If _ImageSearch($imagepath, 0, $x, $y, $tol) Then
If $clickyes = True Then
ClickIt($xoff, $yoff)
ElseIf $clickyes = False Then
MoveIt($xoff, $yoff)
EndIf
Return 1
ToolTip("")
ExitLoop 1
EndIf
Sleep(500)
$t = $t + 0.5
If $t = $seconds AND $skip = True Then
Return 2
ToolTip("")
ExitLoop 1
ElseIf $t = $seconds AND Not $skip AND Not _ImageSearch($imagepath, 0, $x, $y, $tol) Then
$return = MsgBox(2, "Error", "Unable to find image " & $imagepath & ", continue?") ; Abort (3), Retry (4), Ignore (5)
If $return = 3 Then
Exit
ElseIf $return = 4 Then
$t = 0
ElseIf $return = 5 Then
Return 0
ToolTip("")
ExitLoop 1
EndIf
EndIf
WEnd
EndFunc
WinWaitActive($HW,"")
FindImage('Images\Tower.bmp', True, True)
FindImage('Images\Tower-InstantClear.bmp', True, False)
FindImage('Images\Tower-ChooseChests.bmp', True, False)
Do
Sleep(250)
$done = False
Do
If _ImageSearch('Images\Tower-Level-Chest1.bmp', 0, $x, $y, 100) then
ClickIt()
$done = True
ExitLoop
EndIf
Sleep(50)
If _ImageSearch('Images\Tower-Level-Chest2.bmp', 0, $x, $y, 120) then
ClickIt()
$done = True
ExitLoop
EndIf
Sleep(50)
If _ImageSearch('Images\Tower-Level-Chest3.bmp', 0, $x, $y, 120) then
ClickIt()
$done = True
$final = True
ExitLoop
EndIf
Until $done
FindImage('Images\08-Open.bmp', True, False)
If $final Then
Sleep(1000)
FindImage('Images\00-Close.bmp', True, False)
Else
FindImage('Images\09-Proceed.bmp', True, False)
EndIf
Sleep(1000)
Until $final
FindImage('Images\Tower-SkullCoins.bmp', True, False)
FindImage('Images\Tower-SkullCoinsExchange.bmp', True, False)
FindImage('Images\Tower-Points.bmp', True, False)
FindImage('Images\Tower-PointsReward.bmp', True, False)
FindImage('Images\00-Close.bmp', True, False)
Sleep(500)
FindImage('Images\00-Close.bmp', True, False)