Saturday, March 14, 2009

Darkfall autoclicker script for AutoIT - macro that auto clicks for you

Darkfall is a recently released MMO game. As in many other MMOs gathering and crafting mostly consists of pressing the same button over and over at the same spot.

This can be a bit tedious to say the least, but the Darkfall team recently stated in a post on their forums here that it's OK to use macros, as long as you don't go AFK.

An autoclicking macro will help you with both gathering and crafting in Darkfall, by clicking for you at regular intervals.

So I guess a lot of folks are asking right now, how does this work? Well I'll give you my solution.

We'll be using a program called AutoIT. This program sends key/mouse presses to Darkfall. It does not modify the game in any way.

First you need to download and install AutoIT from here: http://www.autoitscript.com/autoit3/

After you have installed AutoIT, create a new text file somewhere on your computer. Name this file something like DarkfallAutoClicker.au3 (the .au3 is important).

In this file you put the script below. After you have saved it, you should be able to just double-click it to start.

How to use
F1: Run / Pause
F3: Shorter delay
F4: Longer delay
F5-F8: Speed 1/2/3/4

The default speeds for F5-F8 can be set in the script (in milliseconds) and the hotkeys can be changed aswell.

Should be pretty straightforward.. Here is the script:

; ----------------------------------------------------
;
; Darkfall AutoClicker script for AutoIT
; 
; The script below is released into the public domain
; by me, the author 
;
; http://lostontheintarweb.blogspot.com/
;
; AutoIT can be found at http://www.autoitscript.com/autoit3/
;


; --- Configurable constants ---

; Default speeds for F4-F8
Const $speed_1 = 5200
Const $speed_2 = 10200
Const $speed_3 = 15200
Const $speed_4 = 21200

; Minimum and maximum speed
; To avoid nasty stuff like negative speed
Const $min_speed = 1000
Const $max_speed = 120000

; F3-F4 will vary the speed with this amount
Const $speed_step = 1000

; Fade time for tray-bubble
Const $bubble_fade_time = 1000

; --- Hotkey Definition ---
; + is SHIFT ^ for CTRL and ! for ALT
; Read more here: http://www.autoitscript.com/autoit3/docs/functions/Send.htm
HotKeySet("+{F1}", "Toggle")

HotKeySet("+{F3}", "SpeedDown")
HotKeySet("+{F4}", "SpeedUp")

HotKeySet("+{F5}", "Speed1")
HotKeySet("+{F6}", "Speed2")
HotKeySet("+{F7}", "Speed3")
HotKeySet("+{F8}", "Speed4")

; --- User configurable variables end here ---
; --- Do not edit below unless you know what you are doing ---


Global $run = False   ; Runs while true
Global $speed = $speed_1 ; Default is speed_1
Global $fade = False  ; After bubble
Global $fadetime   ; Time bubble starts
Global $click = False  ; Click-in-progress
Global $clicktime   ; Time of last click


; Displays tray bubble
Func Bubble($text)
 TrayTip("Darkfall AutoClicker", $text, 5)
 $fade = True
 $fadetime = TimerInit()
EndFunc

; Increase speed
Func SpeedUp()
 $speed = $speed + $speed_step
 If $speed > $max_speed Then
  $speed = $max_speed
 EndIf
 Bubble(StringFormat("Speed set to: %d", $speed))
EndFunc

; Decrease speed
Func SpeedDown()
 $speed = $speed - $speed_step
 If $speed < $min_speed Then
  $speed = $min_speed
 EndIf
 Bubble(StringFormat("Speed set to: %d", $speed))
EndFunc

; Set speed 1
Func Speed1()
 $speed = $speed_1
 Bubble(StringFormat("Speed set to: %d", $speed))
EndFunc

; Set speed 2
Func Speed2()
 $speed = $speed_2
 Bubble(StringFormat("Speed set to: %d", $speed))
EndFunc

; Set speed 3
Func Speed3()
 $speed = $speed_3
 Bubble(StringFormat("Speed set to: %d", $speed))
EndFunc

; Set speed 4
Func Speed4()
 $speed = $speed_4
 Bubble(StringFormat("Speed set to: %d", $speed))
EndFunc

; Toggle run/pause
Func Toggle()
 $run = NOT $run
 If $run Then
  Bubble(StringFormat("Running at speed: %d", $speed))
  TraySetIcon("explorer.exe",110)
 Else
  Bubble("Paused")
  TraySetIcon("explorer.exe",111)
 EndIf
EndFunc

; --- Function definitions end here ---
; --- Start of main routine ---
TraySetIcon("explorer.exe",111)
Bubble("Darkfall AutoClicker started")
WinActivate ( "Darkfall Online" ) 

While 1
 ; Fade out bubble now?
 If $fade Then
  If TimerDiff($fadetime) > 1000 Then
   $fade = False
   Bubble("")
  EndIf
 EndIf
 
 ; Run mode?
 If $run Then
  If Not $click Then  ; First click
   WinWaitActive("Darkfall Online")
   MouseClick("left")
   $click = True
   $clicktime = TimerInit()
  Else
   ; Delay has passed, time for new click
   If TimerDiff($clicktime) > $speed Then
    $click = False
   EndIf
  EndIf
 EndIf

 Sleep(50) ; IMPORTANT! Don't eat too much CPU
WEnd
; ----------------------------------------------------

2 comments:

Anonymous said...

I copyed the script to AutoIt, but when I double click the "DARKFALLAUTOCLICK".au3 no error appears, but a red x comes to my bar and when I my mouse to it, it says "(Paused) AutoIt - DARKFALLAUTOCLICK.au3 "

Anonymous said...

I have the same problem with the script being paused... how do I activate it? Clicking the icon in the bottom right corner of windows just unpauses and repauses it at once.