Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Clicker Heroes AutoHotkey script
- ; Version: 0.1
- ; Date: 4/23/2015
- ; Author: Andrux51 (http://github.com/Andrux51)
- ;
- ; This script will auto-click the Clicker Heroes game window while attempting
- ; to collect all "clickables" (currently Easter Eggs) including the moving one.
- ; The clicks per second should average roughly 50 consistently.
- ; Other scripts may spike higher (I got as high as 90) but this is inconsistent.
- ;
- ; The script will not attempt to use skills, level characters, or anything else.
- ; These features may be added in the future but are not a priority for now.
- ;
- ; Instructions:
- ; - Run .ahk file
- ; - Make sure the Clicker Heroes game tab is visible in your browser
- ; - F7 will begin (and resume when paused) the clicker
- ; - F8 will pause the clicker
- ; - F10 will exit the script entirely
- ;
- ; The script should detect when the user leaves the CH tab of the browser and
- ; pause automatically. Hitting F7 again will resume.
- ;
- #SingleInstance force ; if script is opened again, replace instance
- #Persistent ; script stays in memory until ExitApp is called or script crashes
- global title := "- Clicker Heroes"
- global stop := false
- global timing
- global w := 1136 ; Flash panel is 1136px wide with auto margin
- global leftMargin
- global h := 132 ; Logo takes up 132px from top of browser window
- global topMargin
- ; We will get position of browser window with CH inside in a function below
- global chWidth
- global chHeight
- global chX
- global chY
- ; F7 will begin/resume the auto-clicker
- F7::
- slacktivate(145, 50, false)
- return
- F11::
- slacktivate(145, 15, true)
- return
- ; F8 will pause the auto-clicker
- F8::
- stop := true
- return
- ; F9 will allow for time to buy guys/skills etc without losing combo
- F9::
- slacktivate(1000, 1, false)
- return
- ; F10 will exit the script entirely
- F10::
- ExitApp
- return
- ; pass in milliseconds to adjust click speed
- ; pass in priority level for clickables
- ; ; higher number means more clicks on moving clickable, less for others
- slacktivate(milli, p, levelup) {
- timing := milli
- stop := false
- SetMouseDelay 0
- SetControlDelay 0
- ; We get the position and width/height of the browser window
- getWindowAttributes()
- i = 0
- ; Send clicks to CH while the script is active (press F8 to stop)
- while(!stop) {
- checkActiveWindow()
- ;Click
- ; try to catch skill bonus clickable
- ; high priority- this requires a lot of focused clicks
- getSkillBonusClickable()
- ; low priority- other clickables are moderately rare
- if(i > p) {
- ; try to get other clickables
- getClickables()
- if(levelup) {
- levelGildedHero()
- }
- i = 0
- }
- i++
- Sleep %timing%
- }
- return
- }
- getWindowAttributes() {
- SetTitleMatchMode 2 ; window title contains the string supplied
- ; Activate browser window that contains Clicker Heroes tab
- ; Only if Clicker Heroes is the current tab
- WinActivate %title%
- ; get position of browser window with CH inside
- WinGetPos, chX, chY, chWidth, chHeight, %title%
- leftMargin := (chWidth - w)/2
- if(chHeight < 900) {
- topMargin := h
- } else {
- topMargin := 0
- }
- return
- }
- checkActiveWindow() {
- ; Stop looping if CH browser window is not active
- ; This allows the user to click away without their mouse going ape
- if not WinActive(title) {
- stop := true
- Exit 0
- }
- return
- }
- levelGildedHero() {
- Send {z down}
- ;ControlClick, % "x" leftMargin+140 " y" 500-topMargin, %title%,,, NA
- ControlClick, % "x" leftMargin+140 " y" 780-topMargin, %title%,,, NA
- Send {z up}
- }
- getSkillBonusClickable() {
- checkActiveWindow()
- ; click in a sequential area to try to catch mobile clickable
- ControlClick, % "x" leftMargin+780 " y" 340-topMargin, %title%,,, NA
- ControlClick, % "x" leftMargin+800 " y" 340-topMargin, %title%,,, NA
- ControlClick, % "x" leftMargin+880 " y" 340-topMargin, %title%,,, NA
- ControlClick, % "x" leftMargin+900 " y" 340-topMargin, %title%,,, NA
- ControlClick, % "x" leftMargin+980 " y" 340-topMargin, %title%,,, NA
- ControlClick, % "x" leftMargin+1000 " y" 340-topMargin, %title%,,, NA
- return
- }
- getClickables() {
- checkActiveWindow()
- ; clickable positions
- ControlClick, % "x" leftMargin+515 " y" 670-topMargin, %title%,,, NA
- ControlClick, % "x" leftMargin+740 " y" 610-topMargin, %title%,,, NA
- ControlClick, % "x" leftMargin+755 " y" 560-topMargin, %title%,,, NA
- ControlClick, % "x" leftMargin+860 " y" 690-topMargin, %title%,,, NA
- ControlClick, % "x" leftMargin+1000 " y" 635-topMargin, %title%,,, NA
- ControlClick, % "x" leftMargin+1040 " y" 620-topMargin, %title%,,, NA
- return
- }
Advertisement
Add Comment
Please, Sign In to add comment