View difference between Paste ID: BqcUHxYE and 8VK9GW2L
SHOW: | | - or go back to the newest paste.
1
; Clicker Heroes AutoHotkey script
2
; Version: 0.1
3
; Date: 4/23/2015
4
; Author: Andrux51 (http://github.com/Andrux51)
5
;
6
; This script will auto-click the Clicker Heroes game window while attempting
7
; to collect all "clickables" (currently Easter Eggs) including the moving one.
8
; The clicks per second should average roughly 50 consistently.
9
; Other scripts may spike higher (I got as high as 90) but this is inconsistent.
10
; 
11
; The script will not attempt to use skills, level characters, or anything else.
12
; These features may be added in the future but are not a priority for now.
13
;
14
; Instructions:
15
; - Run .ahk file
16
; - Make sure the Clicker Heroes game tab is visible in your browser
17
; - F7 will begin (and resume when paused) the clicker
18
; - F8 will pause the clicker
19-
; - F10 will exit the script entirely
19+
; - F9 will decrease the clicking timer so that you can buy abilities or w/e while not losing stacks.
20
; - F10 turns off timer
21
; - F11 levels 4th position hero
22
;
23
; The script should detect when the user leaves the CH tab of the browser and
24
; pause automatically. Hitting F7 again will resume.
25
; 
26
27
#SingleInstance force ; if script is opened again, replace instance
28
#Persistent ; script stays in memory until ExitApp is called or script crashes
29
30
global title := "- Clicker Heroes"
31
global stop := false
32
global timing
33
34
global w := 1136 ; Flash panel is 1136px wide with auto margin
35
global leftMargin
36
global h := 132 ; Logo takes up 132px from top of browser window
37
global topMargin
38
39
; We will get position of browser window with CH inside in a function below
40
global chWidth
41
global chHeight
42
global chX
43
global chY
44
45
; F7 will begin/resume the auto-clicker
46
F7::
47
    slacktivate(145, 50, false)
48
    return
49
50
F11::
51
    slacktivate(145, 15, true)
52
    return
53
54
; F8 will pause the auto-clicker
55
F8::
56
    stop := true
57
    return
58
59
; F9 will allow for time to buy guys/skills etc without losing combo
60
F9::
61
    slacktivate(1000, 1, false)
62-
; F10 will exit the script entirely
62+
63-
F10::
63+
64-
    ExitApp
64+
; F10 turns off timer
65
f10::reload ; turns off timer
66
67
; pass in milliseconds to adjust click speed
68
; pass in priority level for clickables
69
; ; higher number means more clicks on moving clickable, less for others
70
slacktivate(milli, p, levelup) {
71
    timing := milli
72
    stop := false
73
    SetMouseDelay 0
74
    SetControlDelay 0
75
76
    ; We get the position and width/height of the browser window
77
    getWindowAttributes()
78
79
    i = 0
80
    ; Send clicks to CH while the script is active (press F8 to stop)
81
    while(!stop) {
82
        checkActiveWindow()
83
        
84
        ;Click
85
        ; try to catch skill bonus clickable
86
        ; high priority- this requires a lot of focused clicks
87
        getSkillBonusClickable()
88
89
        ; low priority- other clickables are moderately rare
90
        if(i > p) {
91
            ; try to get other clickables
92
            getClickables()
93
            if(levelup) {
94
                levelGildedHero()
95
            }
96
            i = 0
97
        }
98
99
        i++
100
        Sleep %timing%
101
    }
102
103
    return
104
}
105
106
getWindowAttributes() {
107
    SetTitleMatchMode 2 ; window title contains the string supplied
108
109
    ; Activate browser window that contains Clicker Heroes tab
110
    ; Only if Clicker Heroes is the current tab
111
    WinActivate %title%
112
113
    ; get position of browser window with CH inside
114
    WinGetPos, chX, chY, chWidth, chHeight, %title%
115
    leftMargin := (chWidth - w)/2
116
    if(chHeight < 900) {
117
        topMargin := h
118
    } else {
119
        topMargin := 0
120
    }
121
122
    return
123
}
124
125
checkActiveWindow() {
126
    ; Stop looping if CH browser window is not active
127
    ; This allows the user to click away without their mouse going ape
128-
    if not WinActive(title) {
128+
;    if not WinActive(title) {
129-
        stop := true
129+
;        stop := true
130-
        Exit 0
130+
;        Exit 0
131
;    }
132
133
    return
134
}
135
136
levelGildedHero() {
137-
    Send {z down}
137+
    Send {q down}
138
    ;ControlClick, % "x" leftMargin+140 " y" 500-topMargin, %title%,,, NA
139
    ControlClick, % "x" leftMargin+140 " y" 780-topMargin, %title%,,, NA
140-
    Send {z up}
140+
    Send {q up}
141
    Send, {8}{3}{7}{5}{4}{1}{2}
142
}
143
144
getSkillBonusClickable() {
145
    checkActiveWindow()
146
147
    ; click in a sequential area to try to catch mobile clickable
148
    ControlClick, % "x" leftMargin+780 " y" 340-topMargin, %title%,,, NA
149
    ControlClick, % "x" leftMargin+800 " y" 340-topMargin, %title%,,, NA
150
    ControlClick, % "x" leftMargin+880 " y" 340-topMargin, %title%,,, NA
151
    ControlClick, % "x" leftMargin+900 " y" 340-topMargin, %title%,,, NA
152
    ControlClick, % "x" leftMargin+980 " y" 340-topMargin, %title%,,, NA
153
    ControlClick, % "x" leftMargin+1000 " y" 340-topMargin, %title%,,, NA
154
155
    return
156
}
157
158
getClickables() {
159
    checkActiveWindow()
160
161
    ; clickable positions
162
    ControlClick, % "x" leftMargin+515 " y" 670-topMargin, %title%,,, NA
163
    ControlClick, % "x" leftMargin+740 " y" 610-topMargin, %title%,,, NA
164
    ControlClick, % "x" leftMargin+755 " y" 560-topMargin, %title%,,, NA
165
    ControlClick, % "x" leftMargin+860 " y" 690-topMargin, %title%,,, NA
166
    ControlClick, % "x" leftMargin+1000 " y" 635-topMargin, %title%,,, NA
167
    ControlClick, % "x" leftMargin+1040 " y" 620-topMargin, %title%,,, NA
168
169
    return
170
}