Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; All of these minus 8 hours (time for DR by default) so that on first run, all skills
  2. ; are triggered.
  3. global last_cs_ps := UnixTimeStamp(A_NOW) - 28800 ; last clickstorm and powersurge
  4. global last_ls_md := UnixTimeStamp(A_NOW) - 28800 ; last lucky strikes and metal detector
  5. global last_gc_sc := UnixTimeStamp(A_NOW) - 28800 ; last golden clicks
  6. global last_dr := UnixTimeStamp(A_NOW) - 28800    ; last dark ritual combo
  7. global dr_stage = 3
  8.  
  9. ;setmousedelay -1
  10. ;setbatchlines -1
  11. global Count = 0
  12. global Stop = 0
  13.  
  14. global vaagur_level = 15 ;This is the level of Vaagur, edit it to fit your own
  15.  
  16. global HoldClicker := 0
  17.  
  18. ;This function takes an input timestamp in the form YYYYMMDDHHMISS and converts
  19. ;it into a UNIX standard epoch timestamp (ie. The number of seconds since
  20. ;Jan 1, 1970). It will only work for dates from 1970 to 2400 (which is the next
  21. ;year in which the leap year rules are different).
  22. ;If you feed in an incorrectly formatted parameter the function will
  23. ;return a string detailing the error.
  24.  
  25. UnixTimeStamp(time_orig)
  26. {
  27.   ;Check that input parameter is correct format.
  28.   StringLen, date_len, time_orig
  29.   If date_len<>14
  30.     return "The input parameter has incorrect length or is an incorrect number format."
  31.   If time_orig is not integer
  32.     return "The input parameter is an incorrect number format."
  33.  
  34.   ;Split date into useable parts
  35.   StringLeft, now_year, time_orig, 4
  36.   StringMid, now_month, time_orig, 5, 2
  37.   StringMid, now_day, time_orig, 7, 2
  38.   StringMid, now_hour, time_orig, 9, 2
  39.   StringMid, now_min, time_orig, 11, 2
  40.   StringRight, now_sec, time_orig, 2
  41.  
  42.   ;Get year seconds
  43.   year_sec := 31536000*(now_year - 1970)
  44.  
  45.   ;Determine how many leap days
  46.   leap_days := (now_year - 1972)/4 + 1
  47.   Transform, leap_days, Floor, %leap_days%
  48.  
  49.   ;Determine if date is in a leap year, and if the leap day has been yet
  50.   this_leap := now_year/4
  51.   Transform, this_leap_round, Floor, %this_leap%
  52.   If (this_leap = this_leap_round)
  53.     {
  54.     If now_month <= 2
  55.       leap_days--   ;subtracts 1 because this year's leap day hasn't been yet
  56.     }
  57.   leap_sec := leap_days*86400
  58.  
  59.   ;Determine fully completed months
  60.   If now_month = 01
  61.     month_sec = 0
  62.   If now_month = 02
  63.     month_sec = 2678400
  64.   If now_month = 03
  65.     month_sec = 5097600
  66.   If now_month = 04
  67.     month_sec = 7776000
  68.   If now_month = 05
  69.     month_sec = 10368000
  70.   If now_month = 06
  71.     month_sec = 13046400
  72.   If now_month = 07
  73.     month_sec = 15638400
  74.   If now_month = 08
  75.     month_sec = 18316800
  76.   If now_month = 09
  77.     month_sec = 20995200
  78.   If now_month = 10
  79.     month_sec = 23587200
  80.   If now_month = 11
  81.     month_sec = 26265600
  82.   If now_month = 12
  83.     month_sec = 28857600
  84.  
  85.    
  86.   ;Determine fully completed days
  87.   day_sec := (now_day - 1)*86400
  88.  
  89.   ;Determine fully completed hours
  90.   hour_sec := now_hour*3600 ;don't subtract 1 because it starts at 0
  91.  
  92.  ;Determine fully completed minutes
  93.  min_sec := now_min*60
  94.  
  95.  ;Calculate total seconds
  96.  date_sec := year_sec + month_sec + day_sec + leap_sec + hour_sec + min_sec + now_sec
  97.  
  98.  return date_sec
  99. }
  100.  
  101. F7::
  102.  DetectHiddenWindows, on
  103.  SetTitleMatchMode Regex
  104.  
  105.  ; Grab the Clicker Heroes HWND, we'll need it later!
  106.   ch_hwnd := WinExist("Lvl\s+\d+\s+-\s+Clicker\s+Heroes")
  107.  
  108.   ; Is Clicker Heroes even running?
  109.   if(!ch_hwnd) {
  110.     MsgBox, Clicker heroes is not running!
  111.     return
  112.   }
  113.  
  114.   ; The HWND of the browser window is great, but what we *really* want is the HWND of the flash control.
  115.   MouseGetPos , ch_mouse_x       ; outputvarx
  116.               , ch_mouse_y       ; outputvary
  117.               , ch_hwnd          ; outputvarwin - the HWND of the parent window
  118.               , ch_control       ; outputvarcontrol - the "classNN" of literally clicker heroes
  119.               , 2  
  120.  
  121.   ; determine if CH is active. Get the title and window class name while we're at it.
  122.  ch_active := WinActive(ahk_id %ch_hwnd%)
  123.  WinGetClass, ch_class, ahk_id %ch_hwnd%
  124.  WinGetTitle, ch_title, ahk_id %ch_hwnd%
  125.  
  126.  ; Make sure we're actually on point.
  127.   if(!ch_active)
  128.   {
  129.     MsgBox, Clicker heroes open, but is not the active window! Please click a monster and try again.
  130.     return
  131.   }
  132.  
  133.   ; development debug
  134.   current_unix_time := UnixTimeStamp(A_NOW)
  135.   OutputDebug % "CH AutoHotKey clicker initiation, current time is " . (current_unix_time)
  136.  
  137.   ; Statistical variables
  138.   click_count := 0
  139.   start_time := UnixTimeStamp(A_NOW)
  140.  
  141.   active_time := current_unix_time - 5 ; the last time the window was newly activated
  142.   pause_clicking := 0                  ; whether or not clicking is paused
  143.   last_pause := current_unix_time - 2  ; the last time the pause key was detected
  144.    
  145.   Loop {
  146.    
  147.     current_unix_time := UnixTimeStamp(A_NOW)
  148.  
  149.     ; Detect if we're no longer active, or if the status has changed!
  150.    old_active := ch_active
  151.    ch_active := WinActive(ahk_id %ch_hwnd%)
  152.    WinGetClass, ch_class, ahk_id %ch_hwnd%
  153.    WinGetTitle, ch_title, ahk_id %ch_hwnd%
  154.  
  155.    ; Have we gone from inactive to active?
  156.    if (!old_active && ch_active)
  157.    {
  158.      active_time := current_unix_time      
  159.    }
  160.  
  161.    ; Wait five seconds after the window has become active to start (give the user time to get the cursor in place),
  162.    ; and only do this if CH is the active window.
  163.    if (current_unix_time - active_time >= 5 && ch_active)
  164.    {
  165.      ; Click and then run the next iteration, but only if the clicking is not paused!
  166.      if (!pause_clicking) {
  167.        Click
  168.        click_count++
  169.      }
  170.      Sleep, 40
  171.    
  172.    }
  173.    
  174.    If (GetKeyState("F8","P")=1) {
  175.      OutputDebug % "Bailing out of Clicker Heroes AutoClick!"
  176.      run_time := (current_unix_time - start_time)
  177.      MsgBox % "Done with run!`n`n"
  178.             . "Ran for " . run_time . "s, avg. clicks per second: " . Floor(click_count/run_time)
  179.  
  180.      BREAK
  181.    }
  182.  }
  183.  Return
  184.  
  185.  
  186. F9::
  187.  DetectHiddenWindows, on
  188.  SetTitleMatchMode Regex
  189.  
  190.  ; Grab the Clicker Heroes HWND, we'll need it later!
  191.   ch_hwnd := WinExist("Lvl\s+\d+\s+-\s+Clicker\s+Heroes")
  192.  
  193.   ; Is Clicker Heroes even running?
  194.   if(!ch_hwnd) {
  195.     MsgBox, Clicker heroes is not running!
  196.     return
  197.   }
  198.  
  199.   ; determine if CH is active. Get the title and window class name while we're at it.
  200.  ch_active := WinActive(ahk_id %ch_hwnd%)
  201.  WinGetClass, ch_class, ahk_id %ch_hwnd%
  202.  WinGetTitle, ch_title, ahk_id %ch_hwnd%
  203.  
  204.  ; Make sure we're actually on point.
  205.   if(!ch_active)
  206.   {
  207.     MsgBox, Clicker heroes open, but is not the active window! Please click a monster and try again.
  208.     return
  209.   }
  210.  
  211.   ; development debug
  212.   current_unix_time := UnixTimeStamp(A_NOW)
  213.   OutputDebug % "CH AutoHotKey clicker initiation, current time is " . (current_unix_time)
  214.  
  215.   dr_time := (3600000 * (1 - (vaagur_level * 0.05)))/1000 ; total cooldown for high-level power-ups (15m with vaagur maxed)
  216.   cs_ps_time := (dr_time/6)  ; clickstorm and powersurge cool down in a sixth of the time
  217.   ls_md_time := (dr_time/2)  ; clickstorm and powersurge cool down in half the time
  218.   gc_sc_time := dr_time      ; superclicks cool down in the same time as energize/reload
  219.  
  220.   ; Statistical variables
  221.   cs_ps_count := 0
  222.   ls_md_count := 0
  223.   gc_sc_count := 0
  224.   dr_count := 0
  225.   click_count := 0
  226.   start_time := UnixTimeStamp(A_NOW)
  227.  
  228.   active_time := current_unix_time - 5 ; the last time the window was newly activated
  229.   pause_clicking := 0                  ; whether or not clicking is paused
  230.   last_pause := current_unix_time - 2  ; the last time the pause key was detected
  231.    
  232.   Loop {
  233.    
  234.     current_unix_time := UnixTimeStamp(A_NOW)
  235.  
  236.     ; Detect if we're no longer active, or if the status has changed!
  237.    old_active := ch_active
  238.    ch_active := WinActive(ahk_id %ch_hwnd%)
  239.    WinGetClass, ch_class, ahk_id %ch_hwnd%
  240.    WinGetTitle, ch_title, ahk_id %ch_hwnd%
  241.  
  242.    ; Have we gone from inactive to active?
  243.    if (!old_active && ch_active)
  244.    {
  245.      active_time := current_unix_time      
  246.    }
  247.  
  248.    ; Wait five seconds after the window has become active to start (give the user time to get the cursor in place),
  249.    ; and only do this if CH is the active window.
  250.    if (current_unix_time - active_time >= 5 && ch_active)
  251.    {
  252.      ; Handle dark ritual stage combo stage 2.
  253.      If (dr_stage == 1 && (current_unix_time - last_dr) > dr_time)
  254.      {
  255.        OutputDebug, "Sending DARK RITUAL stage 2"
  256.        Send 8
  257.        Send 9
  258.        last_dr := current_unix_time
  259.        dr_stage := 0      
  260.      }
  261.      
  262.      ; Handle clickstorm and powersurge. With maxed vaagur, this can happen every 2m30s.
  263.      If (dr_stage != 1 && (current_unix_time - last_cs_ps) > cs_ps_time)
  264.      {
  265.        OutputDebug, "Sending ClickStorm and PowerSurge"
  266.        
  267.        ; Send CS/PS combo - 1,2!
  268.        Send 1
  269.        Send 2
  270.        
  271.        last_cs_ps := current_unix_time
  272.        cs_ps_count++
  273.      }
  274.      
  275.      ; Handle lucky strikes and metal detector. With maxed vaagur, this can happen every 7m30s.
  276.      If (dr_stage != 1 && (current_unix_time - last_ls_md) > ls_md_time)
  277.      {
  278.        OutputDebug, "Sending Lucky Strikes and Metal Detector"
  279.        
  280.        ; Send LS/MD combo - 3,4!
  281.        Send 3
  282.        Send 4
  283.        
  284.        last_ls_md := current_unix_time    
  285.        ls_md_count++        
  286.      }
  287.          
  288.      ; Handle golden clicks and super clicks. With maxed vaagur, this can happen every 15m.
  289.      If (dr_stage != 1 && (current_unix_time - last_gc_sc) > gc_sc_time)
  290.      {
  291.        OutputDebug, "Sending golden clicks and super clicks"
  292.        
  293.        ; Send GC/SC combo - 5,7!
  294.        Send 5
  295.        Send 7
  296.        
  297.        last_gc_sc := current_unix_time
  298.        gc_sc_count++
  299.      }
  300.      
  301.      ; Handle dark ritual combo part 1. After this, no other skills can be used until dark ritual part 2 - we need
  302.      ; to save the energize and reload for Dark Ritual.
  303.      If ((dr_stage == 0 || dr_stage == 3) && (current_unix_time - last_dr) > dr_time)
  304.      {
  305.        OutputDebug, "Sending DARK RITUAL stage 1"
  306.        
  307.        ; Send DR combo - 8,6,9!
  308.        Send 8
  309.        Send 6
  310.        Send 9
  311.        
  312.        last_dr := current_unix_time
  313.        dr_stage := 1
  314.        dr_count++
  315.      }        
  316.      
  317.      ; Click and then run the next iteration, but only if the clicking is not paused!
  318.      if (!pause_clicking) {
  319.        Click
  320.        click_count++
  321.      }
  322.      Sleep, 40
  323.    
  324.    }; All of these minus 8 hours (time for DR by default) so that on first run, all skills
  325. ; are triggered.
  326. global last_cs_ps := UnixTimeStamp(A_NOW) - 28800 ; last clickstorm and powersurge
  327. global last_ls_md := UnixTimeStamp(A_NOW) - 28800 ; last lucky strikes and metal detector
  328. global last_gc_sc := UnixTimeStamp(A_NOW) - 28800 ; last golden clicks
  329. global last_dr := UnixTimeStamp(A_NOW) - 28800    ; last dark ritual combo
  330. global dr_stage = 3
  331.  
  332. ;setmousedelay -1
  333. ;setbatchlines -1
  334. global Count = 0
  335. global Stop = 0
  336.  
  337. global vaagur_level = 15 ;This is the level of Vaagur, edit it to fit your own
  338.  
  339. global HoldClicker := 0
  340.  
  341. ;This function takes an input timestamp in the form YYYYMMDDHHMISS and converts
  342. ;it into a UNIX standard epoch timestamp (ie. The number of seconds since
  343. ;Jan 1, 1970). It will only work for dates from 1970 to 2400 (which is the next
  344. ;year in which the leap year rules are different).
  345. ;If you feed in an incorrectly formatted parameter the function will
  346. ;return a string detailing the error.
  347.  
  348. UnixTimeStamp(time_orig)
  349. {
  350.  ;Check that input parameter is correct format.
  351.  StringLen, date_len, time_orig
  352.  If date_len<>14
  353.    return "The input parameter has incorrect length or is an incorrect number format."
  354.  If time_orig is not integer
  355.    return "The input parameter is an incorrect number format."
  356.  
  357.  ;Split date into useable parts
  358.  StringLeft, now_year, time_orig, 4
  359.  StringMid, now_month, time_orig, 5, 2
  360.  StringMid, now_day, time_orig, 7, 2
  361.  StringMid, now_hour, time_orig, 9, 2
  362.  StringMid, now_min, time_orig, 11, 2
  363.  StringRight, now_sec, time_orig, 2
  364.  
  365.  ;Get year seconds
  366.  year_sec := 31536000*(now_year - 1970)
  367.  
  368.  ;Determine how many leap days
  369.  leap_days := (now_year - 1972)/4 + 1
  370.  Transform, leap_days, Floor, %leap_days%
  371.  
  372.  ;Determine if date is in a leap year, and if the leap day has been yet
  373.  this_leap := now_year/4
  374.  Transform, this_leap_round, Floor, %this_leap%
  375.  If (this_leap = this_leap_round)
  376.    {
  377.    If now_month <= 2
  378.      leap_days--   ;subtracts 1 because this year's leap day hasn't been yet
  379.    }
  380.  leap_sec := leap_days*86400
  381.  
  382.  ;Determine fully completed months
  383.  If now_month = 01
  384.    month_sec = 0
  385.  If now_month = 02
  386.    month_sec = 2678400
  387.  If now_month = 03
  388.    month_sec = 5097600
  389.  If now_month = 04
  390.    month_sec = 7776000
  391.  If now_month = 05
  392.    month_sec = 10368000
  393.  If now_month = 06
  394.    month_sec = 13046400
  395.  If now_month = 07
  396.    month_sec = 15638400
  397.  If now_month = 08
  398.    month_sec = 18316800
  399.  If now_month = 09
  400.    month_sec = 20995200
  401.  If now_month = 10
  402.    month_sec = 23587200
  403.  If now_month = 11
  404.    month_sec = 26265600
  405.  If now_month = 12
  406.    month_sec = 28857600
  407.  
  408.    
  409.  ;Determine fully completed days
  410.  day_sec := (now_day - 1)*86400
  411.  
  412.  ;Determine fully completed hours
  413.  hour_sec := now_hour*3600 ;don't subtract 1 because it starts at 0
  414.  
  415.   ;Determine fully completed minutes
  416.   min_sec := now_min*60
  417.  
  418.   ;Calculate total seconds
  419.   date_sec := year_sec + month_sec + day_sec + leap_sec + hour_sec + min_sec + now_sec
  420.  
  421.   return date_sec
  422. }
  423.  
  424. F7::
  425.   DetectHiddenWindows, on
  426.   SetTitleMatchMode Regex
  427.  
  428.   ; Grab the Clicker Heroes HWND, we'll need it later!
  429.  ch_hwnd := WinExist("Lvl\s+\d+\s+-\s+Clicker\s+Heroes")
  430.  
  431.  ; Is Clicker Heroes even running?
  432.  if(!ch_hwnd) {
  433.    MsgBox, Clicker heroes is not running!
  434.    return
  435.  }
  436.  
  437.  ; The HWND of the browser window is great, but what we *really* want is the HWND of the flash control.
  438.  MouseGetPos , ch_mouse_x       ; outputvarx
  439.              , ch_mouse_y       ; outputvary
  440.              , ch_hwnd          ; outputvarwin - the HWND of the parent window
  441.              , ch_control       ; outputvarcontrol - the "classNN" of literally clicker heroes
  442.              , 2  
  443.  
  444.  ; determine if CH is active. Get the title and window class name while we're at it.
  445.   ch_active := WinActive(ahk_id %ch_hwnd%)
  446.   WinGetClass, ch_class, ahk_id %ch_hwnd%
  447.   WinGetTitle, ch_title, ahk_id %ch_hwnd%
  448.  
  449.   ; Make sure we're actually on point.
  450.  if(!ch_active)
  451.  {
  452.    MsgBox, Clicker heroes open, but is not the active window! Please click a monster and try again.
  453.    return
  454.  }
  455.  
  456.  ; development debug
  457.  current_unix_time := UnixTimeStamp(A_NOW)
  458.  OutputDebug % "CH AutoHotKey clicker initiation, current time is " . (current_unix_time)
  459.  
  460.  ; Statistical variables
  461.  click_count := 0
  462.  start_time := UnixTimeStamp(A_NOW)
  463.  
  464.  active_time := current_unix_time - 5 ; the last time the window was newly activated
  465.  pause_clicking := 0                  ; whether or not clicking is paused
  466.  last_pause := current_unix_time - 2  ; the last time the pause key was detected
  467.    
  468.  Loop {
  469.  
  470.    current_unix_time := UnixTimeStamp(A_NOW)
  471.  
  472.    ; Detect if we're no longer active, or if the status has changed!
  473.     old_active := ch_active
  474.     ch_active := WinActive(ahk_id %ch_hwnd%)
  475.     WinGetClass, ch_class, ahk_id %ch_hwnd%
  476.     WinGetTitle, ch_title, ahk_id %ch_hwnd%
  477.  
  478.     ; Have we gone from inactive to active?
  479.     if (!old_active && ch_active)
  480.     {
  481.       active_time := current_unix_time      
  482.     }
  483.  
  484.     ; Wait five seconds after the window has become active to start (give the user time to get the cursor in place),
  485.     ; and only do this if CH is the active window.
  486.     if (current_unix_time - active_time >= 5 && ch_active)
  487.     {
  488.       ; Click and then run the next iteration, but only if the clicking is not paused!
  489.       if (!pause_clicking) {
  490.         Click
  491.         click_count++
  492.       }
  493.       Sleep, 80
  494.      
  495.     }
  496.    
  497.     If (GetKeyState("F8","P")=1) {
  498.       OutputDebug % "Bailing out of Clicker Heroes AutoClick!"
  499.       run_time := (current_unix_time - start_time)
  500.       MsgBox % "Done with run!`n`n"
  501.              . "Ran for " . run_time . "s, avg. clicks per second: " . Floor(click_count/run_time)
  502.  
  503.       BREAK
  504.     }
  505.   }
  506.   Return
  507.  
  508.  
  509. F9::
  510.   DetectHiddenWindows, on
  511.   SetTitleMatchMode Regex
  512.  
  513.   ; Grab the Clicker Heroes HWND, we'll need it later!
  514.  ch_hwnd := WinExist("Lvl\s+\d+\s+-\s+Clicker\s+Heroes")
  515.  
  516.  ; Is Clicker Heroes even running?
  517.  if(!ch_hwnd) {
  518.    MsgBox, Clicker heroes is not running!
  519.    return
  520.  }
  521.  
  522.  ; determine if CH is active. Get the title and window class name while we're at it.
  523.   ch_active := WinActive(ahk_id %ch_hwnd%)
  524.   WinGetClass, ch_class, ahk_id %ch_hwnd%
  525.   WinGetTitle, ch_title, ahk_id %ch_hwnd%
  526.  
  527.   ; Make sure we're actually on point.
  528.  if(!ch_active)
  529.  {
  530.    MsgBox, Clicker heroes open, but is not the active window! Please click a monster and try again.
  531.    return
  532.  }
  533.  
  534.  ; development debug
  535.  current_unix_time := UnixTimeStamp(A_NOW)
  536.  OutputDebug % "CH AutoHotKey clicker initiation, current time is " . (current_unix_time)
  537.  
  538.  dr_time := (3600000 * (1 - (vaagur_level * 0.05)))/1000 ; total cooldown for high-level power-ups (15m with vaagur maxed)
  539.  cs_ps_time := (dr_time/6)  ; clickstorm and powersurge cool down in a sixth of the time
  540.  ls_md_time := (dr_time/2)  ; clickstorm and powersurge cool down in half the time
  541.  gc_sc_time := dr_time      ; superclicks cool down in the same time as energize/reload
  542.  
  543.  ; Statistical variables
  544.  cs_ps_count := 0
  545.  ls_md_count := 0
  546.  gc_sc_count := 0
  547.  dr_count := 0
  548.  click_count := 0
  549.  start_time := UnixTimeStamp(A_NOW)
  550.  
  551.  active_time := current_unix_time - 5 ; the last time the window was newly activated
  552.  pause_clicking := 0                  ; whether or not clicking is paused
  553.  last_pause := current_unix_time - 2  ; the last time the pause key was detected
  554.    
  555.  Loop {
  556.  
  557.    current_unix_time := UnixTimeStamp(A_NOW)
  558.  
  559.    ; Detect if we're no longer active, or if the status has changed!
  560.     old_active := ch_active
  561.     ch_active := WinActive(ahk_id %ch_hwnd%)
  562.     WinGetClass, ch_class, ahk_id %ch_hwnd%
  563.     WinGetTitle, ch_title, ahk_id %ch_hwnd%
  564.  
  565.     ; Have we gone from inactive to active?
  566.     if (!old_active && ch_active)
  567.     {
  568.       active_time := current_unix_time      
  569.     }
  570.  
  571.     ; Wait five seconds after the window has become active to start (give the user time to get the cursor in place),
  572.     ; and only do this if CH is the active window.
  573.     if (current_unix_time - active_time >= 5 && ch_active)
  574.     {
  575.       ; Handle dark ritual stage combo stage 2.
  576.       If (dr_stage == 1 && (current_unix_time - last_dr) > dr_time)
  577.       {
  578.         OutputDebug, "Sending DARK RITUAL stage 2"
  579.         Send 8
  580.         Send 9
  581.         last_dr := current_unix_time
  582.         dr_stage := 0      
  583.       }
  584.      
  585.       ; Handle clickstorm and powersurge. With maxed vaagur, this can happen every 2m30s.
  586.       If (dr_stage != 1 && (current_unix_time - last_cs_ps) > cs_ps_time)
  587.       {
  588.         OutputDebug, "Sending ClickStorm and PowerSurge"
  589.        
  590.         ; Send CS/PS combo - 1,2!
  591.         Send 1
  592.         Send 2
  593.        
  594.         last_cs_ps := current_unix_time
  595.         cs_ps_count++
  596.       }
  597.      
  598.       ; Handle lucky strikes and metal detector. With maxed vaagur, this can happen every 7m30s.
  599.       If (dr_stage != 1 && (current_unix_time - last_ls_md) > ls_md_time)
  600.       {
  601.         OutputDebug, "Sending Lucky Strikes and Metal Detector"
  602.        
  603.         ; Send LS/MD combo - 3,4!
  604.         Send 3
  605.         Send 4
  606.        
  607.         last_ls_md := current_unix_time    
  608.         ls_md_count++        
  609.       }
  610.          
  611.       ; Handle golden clicks and super clicks. With maxed vaagur, this can happen every 15m.
  612.       If (dr_stage != 1 && (current_unix_time - last_gc_sc) > gc_sc_time)
  613.       {
  614.         OutputDebug, "Sending golden clicks and super clicks"
  615.        
  616.         ; Send GC/SC combo - 5,7!
  617.         Send 5
  618.         Send 7
  619.        
  620.         last_gc_sc := current_unix_time
  621.         gc_sc_count++
  622.       }
  623.      
  624.       ; Handle dark ritual combo part 1. After this, no other skills can be used until dark ritual part 2 - we need
  625.       ; to save the energize and reload for Dark Ritual.
  626.       If ((dr_stage == 0 || dr_stage == 3) && (current_unix_time - last_dr) > dr_time)
  627.       {
  628.         OutputDebug, "Sending DARK RITUAL stage 1"
  629.        
  630.         ; Send DR combo - 8,6,9!
  631.         Send 8
  632.         Send 6
  633.         Send 9
  634.        
  635.         last_dr := current_unix_time
  636.         dr_stage := 1
  637.         dr_count++
  638.       }        
  639.      
  640.       ; Click and then run the next iteration, but only if the clicking is not paused!
  641.       if (!pause_clicking) {
  642.         Click
  643.         click_count++
  644.       }
  645.       Sleep, 80
  646.      
  647.     }
  648.    
  649.     If (GetKeyState("F10","P")=1) {
  650.       OutputDebug % "Bailing out of Clicker Heroes AutoClick!"
  651.       run_time := (current_unix_time - start_time)
  652.       MsgBox % "Done with run!`n`n"
  653.              . "Ran for " . run_time . "s, avg. clicks per second: " . Floor(click_count/run_time) . "`n"
  654.              . "`n"
  655.              . "Total ClickStorm/PowerSurge: " . cs_ps_count . "`n"
  656.              . "Total Lucky Strikes/Metal Detector: " . ls_md_count . "`n"
  657.              . "Total Golden Clicks/Super Clicks: " . gc_sc_count . "`n"
  658.              . "Total ENERGIZED DARK RITUAL uses: " . dr_count
  659.       BREAK
  660.     }
  661.    
  662.     ; Toggle the pause clicking state. We can only detect if a key is pressed, and we do that
  663.     ; many times per second, so holding the key down for half a second (as a user would
  664.     ; normally do) would cause hundreds of toggles. Because of this, we only recognize it
  665.     ; once every two seconds. We don't need to do this for F10 because it immediately
  666.    ; breaks from our loop and thus would never trigger again.
  667.    If (GetKeyState("F8","P")=1 && current_unix_time - last_pause > 2) {
  668.      OutputDebug % "Pause clicking trigger!"
  669.      pause_clicking := !pause_clicking
  670.      last_pause := current_unix_time
  671.    }
  672.  }
  673.  Return; All of these minus 8 hours (time for DR by default) so that on first run, all skills
  674. ; are triggered.
  675. global last_cs_ps := UnixTimeStamp(A_NOW) - 28800 ; last clickstorm and powersurge
  676. global last_ls_md := UnixTimeStamp(A_NOW) - 28800 ; last lucky strikes and metal detector
  677. global last_gc_sc := UnixTimeStamp(A_NOW) - 28800 ; last golden clicks
  678. global last_dr := UnixTimeStamp(A_NOW) - 28800    ; last dark ritual combo
  679. global dr_stage = 3
  680.  
  681. ;setmousedelay -1
  682. ;setbatchlines -1
  683. global Count = 0
  684. global Stop = 0
  685.  
  686. global vaagur_level = 15 ;This is the level of Vaagur, edit it to fit your own
  687.  
  688. global HoldClicker := 0
  689.  
  690. ;This function takes an input timestamp in the form YYYYMMDDHHMISS and converts
  691. ;it into a UNIX standard epoch timestamp (ie. The number of seconds since
  692. ;Jan 1, 1970). It will only work for dates from 1970 to 2400 (which is the next
  693. ;year in which the leap year rules are different).
  694. ;If you feed in an incorrectly formatted parameter the function will
  695. ;return a string detailing the error.
  696.  
  697. UnixTimeStamp(time_orig)
  698. {
  699.  ;Check that input parameter is correct format.
  700.  StringLen, date_len, time_orig
  701.  If date_len<>14
  702.    return "The input parameter has incorrect length or is an incorrect number format."
  703.  If time_orig is not integer
  704.    return "The input parameter is an incorrect number format."
  705.  
  706.  ;Split date into useable parts
  707.  StringLeft, now_year, time_orig, 4
  708.  StringMid, now_month, time_orig, 5, 2
  709.  StringMid, now_day, time_orig, 7, 2
  710.  StringMid, now_hour, time_orig, 9, 2
  711.  StringMid, now_min, time_orig, 11, 2
  712.  StringRight, now_sec, time_orig, 2
  713.  
  714.  ;Get year seconds
  715.  year_sec := 31536000*(now_year - 1970)
  716.  
  717.  ;Determine how many leap days
  718.  leap_days := (now_year - 1972)/4 + 1
  719.  Transform, leap_days, Floor, %leap_days%
  720.  
  721.  ;Determine if date is in a leap year, and if the leap day has been yet
  722.  this_leap := now_year/4
  723.  Transform, this_leap_round, Floor, %this_leap%
  724.  If (this_leap = this_leap_round)
  725.    {
  726.    If now_month <= 2
  727.      leap_days--   ;subtracts 1 because this year's leap day hasn't been yet
  728.    }
  729.  leap_sec := leap_days*86400
  730.  
  731.  ;Determine fully completed months
  732.  If now_month = 01
  733.    month_sec = 0
  734.  If now_month = 02
  735.    month_sec = 2678400
  736.  If now_month = 03
  737.    month_sec = 5097600
  738.  If now_month = 04
  739.    month_sec = 7776000
  740.  If now_month = 05
  741.    month_sec = 10368000
  742.  If now_month = 06
  743.    month_sec = 13046400
  744.  If now_month = 07
  745.    month_sec = 15638400
  746.  If now_month = 08
  747.    month_sec = 18316800
  748.  If now_month = 09
  749.    month_sec = 20995200
  750.  If now_month = 10
  751.    month_sec = 23587200
  752.  If now_month = 11
  753.    month_sec = 26265600
  754.  If now_month = 12
  755.    month_sec = 28857600
  756.  
  757.    
  758.  ;Determine fully completed days
  759.  day_sec := (now_day - 1)*86400
  760.  
  761.  ;Determine fully completed hours
  762.  hour_sec := now_hour*3600 ;don't subtract 1 because it starts at 0
  763.  
  764.   ;Determine fully completed minutes
  765.   min_sec := now_min*60
  766.  
  767.   ;Calculate total seconds
  768.   date_sec := year_sec + month_sec + day_sec + leap_sec + hour_sec + min_sec + now_sec
  769.  
  770.   return date_sec
  771. }
  772.  
  773. F7::
  774.   DetectHiddenWindows, on
  775.   SetTitleMatchMode Regex
  776.  
  777.   ; Grab the Clicker Heroes HWND, we'll need it later!
  778.  ch_hwnd := WinExist("Lvl\s+\d+\s+-\s+Clicker\s+Heroes")
  779.  
  780.  ; Is Clicker Heroes even running?
  781.  if(!ch_hwnd) {
  782.    MsgBox, Clicker heroes is not running!
  783.    return
  784.  }
  785.  
  786.  ; The HWND of the browser window is great, but what we *really* want is the HWND of the flash control.
  787.  MouseGetPos , ch_mouse_x       ; outputvarx
  788.              , ch_mouse_y       ; outputvary
  789.              , ch_hwnd          ; outputvarwin - the HWND of the parent window
  790.              , ch_control       ; outputvarcontrol - the "classNN" of literally clicker heroes
  791.              , 2  
  792.  
  793.  ; determine if CH is active. Get the title and window class name while we're at it.
  794.   ch_active := WinActive(ahk_id %ch_hwnd%)
  795.   WinGetClass, ch_class, ahk_id %ch_hwnd%
  796.   WinGetTitle, ch_title, ahk_id %ch_hwnd%
  797.  
  798.   ; Make sure we're actually on point.
  799.  if(!ch_active)
  800.  {
  801.    MsgBox, Clicker heroes open, but is not the active window! Please click a monster and try again.
  802.    return
  803.  }
  804.  
  805.  ; development debug
  806.  current_unix_time := UnixTimeStamp(A_NOW)
  807.  OutputDebug % "CH AutoHotKey clicker initiation, current time is " . (current_unix_time)
  808.  
  809.  ; Statistical variables
  810.  click_count := 0
  811.  start_time := UnixTimeStamp(A_NOW)
  812.  
  813.  active_time := current_unix_time - 5 ; the last time the window was newly activated
  814.  pause_clicking := 0                  ; whether or not clicking is paused
  815.  last_pause := current_unix_time - 2  ; the last time the pause key was detected
  816.    
  817.  Loop {
  818.  
  819.    current_unix_time := UnixTimeStamp(A_NOW)
  820.  
  821.    ; Detect if we're no longer active, or if the status has changed!
  822.     old_active := ch_active
  823.     ch_active := WinActive(ahk_id %ch_hwnd%)
  824.     WinGetClass, ch_class, ahk_id %ch_hwnd%
  825.     WinGetTitle, ch_title, ahk_id %ch_hwnd%
  826.  
  827.     ; Have we gone from inactive to active?
  828.     if (!old_active && ch_active)
  829.     {
  830.       active_time := current_unix_time      
  831.     }
  832.  
  833.     ; Wait five seconds after the window has become active to start (give the user time to get the cursor in place),
  834.     ; and only do this if CH is the active window.
  835.     if (current_unix_time - active_time >= 5 && ch_active)
  836.     {
  837.       ; Click and then run the next iteration, but only if the clicking is not paused!
  838.       if (!pause_clicking) {
  839.         Click
  840.         click_count++
  841.       }
  842.       Sleep, 80
  843.      
  844.     }
  845.    
  846.     If (GetKeyState("F8","P")=1) {
  847.       OutputDebug % "Bailing out of Clicker Heroes AutoClick!"
  848.       run_time := (current_unix_time - start_time)
  849.       MsgBox % "Done with run!`n`n"
  850.              . "Ran for " . run_time . "s, avg. clicks per second: " . Floor(click_count/run_time)
  851.  
  852.       BREAK
  853.     }
  854.   }
  855.   Return
  856.  
  857.  
  858. F9::
  859.   DetectHiddenWindows, on
  860.   SetTitleMatchMode Regex
  861.  
  862.   ; Grab the Clicker Heroes HWND, we'll need it later!
  863.  ch_hwnd := WinExist("Lvl\s+\d+\s+-\s+Clicker\s+Heroes")
  864.  
  865.  ; Is Clicker Heroes even running?
  866.  if(!ch_hwnd) {
  867.    MsgBox, Clicker heroes is not running!
  868.    return
  869.  }
  870.  
  871.  ; determine if CH is active. Get the title and window class name while we're at it.
  872.   ch_active := WinActive(ahk_id %ch_hwnd%)
  873.   WinGetClass, ch_class, ahk_id %ch_hwnd%
  874.   WinGetTitle, ch_title, ahk_id %ch_hwnd%
  875.  
  876.   ; Make sure we're actually on point.
  877.  if(!ch_active)
  878.  {
  879.    MsgBox, Clicker heroes open, but is not the active window! Please click a monster and try again.
  880.    return
  881.  }
  882.  
  883.  ; development debug
  884.  current_unix_time := UnixTimeStamp(A_NOW)
  885.  OutputDebug % "CH AutoHotKey clicker initiation, current time is " . (current_unix_time)
  886.  
  887.  dr_time := (3600000 * (1 - (vaagur_level * 0.05)))/1000 ; total cooldown for high-level power-ups (15m with vaagur maxed)
  888.  cs_ps_time := (dr_time/6)  ; clickstorm and powersurge cool down in a sixth of the time
  889.  ls_md_time := (dr_time/2)  ; clickstorm and powersurge cool down in half the time
  890.  gc_sc_time := dr_time      ; superclicks cool down in the same time as energize/reload
  891.  
  892.  ; Statistical variables
  893.  cs_ps_count := 0
  894.  ls_md_count := 0
  895.  gc_sc_count := 0
  896.  dr_count := 0
  897.  click_count := 0
  898.  start_time := UnixTimeStamp(A_NOW)
  899.  
  900.  active_time := current_unix_time - 5 ; the last time the window was newly activated
  901.  pause_clicking := 0                  ; whether or not clicking is paused
  902.  last_pause := current_unix_time - 2  ; the last time the pause key was detected
  903.    
  904.  Loop {
  905.  
  906.    current_unix_time := UnixTimeStamp(A_NOW)
  907.  
  908.    ; Detect if we're no longer active, or if the status has changed!
  909.     old_active := ch_active
  910.     ch_active := WinActive(ahk_id %ch_hwnd%)
  911.     WinGetClass, ch_class, ahk_id %ch_hwnd%
  912.     WinGetTitle, ch_title, ahk_id %ch_hwnd%
  913.  
  914.     ; Have we gone from inactive to active?
  915.     if (!old_active && ch_active)
  916.     {
  917.       active_time := current_unix_time      
  918.     }
  919.  
  920.     ; Wait five seconds after the window has become active to start (give the user time to get the cursor in place),
  921.     ; and only do this if CH is the active window.
  922.     if (current_unix_time - active_time >= 5 && ch_active)
  923.     {
  924.       ; Handle dark ritual stage combo stage 2.
  925.       If (dr_stage == 1 && (current_unix_time - last_dr) > dr_time)
  926.       {
  927.         OutputDebug, "Sending DARK RITUAL stage 2"
  928.         Send 8
  929.         Send 9
  930.         last_dr := current_unix_time
  931.         dr_stage := 0      
  932.       }
  933.      
  934.       ; Handle clickstorm and powersurge. With maxed vaagur, this can happen every 2m30s.
  935.       If (dr_stage != 1 && (current_unix_time - last_cs_ps) > cs_ps_time)
  936.       {
  937.         OutputDebug, "Sending ClickStorm and PowerSurge"
  938.        
  939.         ; Send CS/PS combo - 1,2!
  940.         Send 1
  941.         Send 2
  942.        
  943.         last_cs_ps := current_unix_time
  944.         cs_ps_count++
  945.       }
  946.      
  947.       ; Handle lucky strikes and metal detector. With maxed vaagur, this can happen every 7m30s.
  948.       If (dr_stage != 1 && (current_unix_time - last_ls_md) > ls_md_time)
  949.       {
  950.         OutputDebug, "Sending Lucky Strikes and Metal Detector"
  951.        
  952.         ; Send LS/MD combo - 3,4!
  953.         Send 3
  954.         Send 4
  955.        
  956.         last_ls_md := current_unix_time    
  957.         ls_md_count++        
  958.       }
  959.          
  960.       ; Handle golden clicks and super clicks. With maxed vaagur, this can happen every 15m.
  961.       If (dr_stage != 1 && (current_unix_time - last_gc_sc) > gc_sc_time)
  962.       {
  963.         OutputDebug, "Sending golden clicks and super clicks"
  964.        
  965.         ; Send GC/SC combo - 5,7!
  966.         Send 5
  967.         Send 7
  968.        
  969.         last_gc_sc := current_unix_time
  970.         gc_sc_count++
  971.       }
  972.      
  973.       ; Handle dark ritual combo part 1. After this, no other skills can be used until dark ritual part 2 - we need
  974.       ; to save the energize and reload for Dark Ritual.
  975.       If ((dr_stage == 0 || dr_stage == 3) && (current_unix_time - last_dr) > dr_time)
  976.       {
  977.         OutputDebug, "Sending DARK RITUAL stage 1"
  978.        
  979.         ; Send DR combo - 8,6,9!
  980.         Send 8
  981.         Send 6
  982.         Send 9
  983.        
  984.         last_dr := current_unix_time
  985.         dr_stage := 1
  986.         dr_count++
  987.       }        
  988.      
  989.       ; Click and then run the next iteration, but only if the clicking is not paused!
  990.       if (!pause_clicking) {
  991.         Click
  992.         click_count++
  993.       }
  994.       Sleep, 80
  995.      
  996.     }
  997.    
  998.     If (GetKeyState("F10","P")=1) {
  999.       OutputDebug % "Bailing out of Clicker Heroes AutoClick!"
  1000.       run_time := (current_unix_time - start_time)
  1001.       MsgBox % "Done with run!`n`n"
  1002.              . "Ran for " . run_time . "s, avg. clicks per second: " . Floor(click_count/run_time) . "`n"
  1003.              . "`n"
  1004.              . "Total ClickStorm/PowerSurge: " . cs_ps_count . "`n"
  1005.              . "Total Lucky Strikes/Metal Detector: " . ls_md_count . "`n"
  1006.              . "Total Golden Clicks/Super Clicks: " . gc_sc_count . "`n"
  1007.              . "Total ENERGIZED DARK RITUAL uses: " . dr_count
  1008.       BREAK
  1009.     }
  1010.    
  1011.     ; Toggle the pause clicking state. We can only detect if a key is pressed, and we do that
  1012.     ; many times per second, so holding the key down for half a second (as a user would
  1013.     ; normally do) would cause hundreds of toggles. Because of this, we only recognize it
  1014.     ; once every two seconds. We don't need to do this for F10 because it immediately
  1015.    ; breaks from our loop and thus would never trigger again.
  1016.    If (GetKeyState("F8","P")=1 && current_unix_time - last_pause > 2) {
  1017.      OutputDebug % "Pause clicking trigger!"
  1018.      pause_clicking := !pause_clicking
  1019.      last_pause := current_unix_time
  1020.    }
  1021.  }
  1022.  Return
  1023.    
  1024.    If (GetKeyState("F10","P")=1) {
  1025.      OutputDebug % "Bailing out of Clicker Heroes AutoClick!"
  1026.      run_time := (current_unix_time - start_time)
  1027.      MsgBox % "Done with run!`n`n"
  1028.             . "Ran for " . run_time . "s, avg. clicks per second: " . Floor(click_count/run_time) . "`n"
  1029.             . "`n"
  1030.             . "Total ClickStorm/PowerSurge: " . cs_ps_count . "`n"
  1031.             . "Total Lucky Strikes/Metal Detector: " . ls_md_count . "`n"
  1032.             . "Total Golden Clicks/Super Clicks: " . gc_sc_count . "`n"
  1033.             . "Total ENERGIZED DARK RITUAL uses: " . dr_count
  1034.      BREAK
  1035.    }
  1036.    
  1037.    ; Toggle the pause clicking state. We can only detect if a key is pressed, and we do that
  1038.    ; many times per second, so holding the key down for half a second (as a user would
  1039.    ; normally do) would cause hundreds of toggles. Because of this, we only recognize it
  1040.    ; once every two seconds. We don't need to do this for F10 because it immediately
  1041.     ; breaks from our loop and thus would never trigger again.
  1042.     If (GetKeyState("F8","P")=1 && current_unix_time - last_pause > 2) {
  1043.       OutputDebug % "Pause clicking trigger!"
  1044.       pause_clicking := !pause_clicking
  1045.       last_pause := current_unix_time
  1046.     }
  1047.   }
  1048.   Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement