AutoHotkey Guide

From Dual-Boxing.com

Jump to: navigation, search

Remark by Gweihir: The construct used in the guide below (cut down to 2 Windows):

~0:: 
KeyWait, 1, D
#IfWinActive, World of Warcraft 
{
ControlSend,, 1, ahk_id %wowid1% 
ControlSend,, 1, ahk_id %wowid2% 
}
Return 

sends the '1' key twice to the active WoW window. I found this when trying to input my password failed (it has digits in it). This happens because first the ~ passes the original key through to the active window and then it is sent again by the ControlSent command.

As the rule by Blizzard is that one keypress may only create on key input per WoW window, I would suggest the use of the following form instead:

$1::             
KeyWait, 1, D  
ifWinActive, World of Warcraft
{                                     
   ControlSend,, 1, ahk_id %wowid1% 
   ControlSend,, 1, ahk_id %wowid2% 
} else {                            
   Send, {1} 
}
Return

This suppresses the key and resends it verbatim if the active window is not WoW. The '$' is needed to allow this re-sending.


Copied from unit187's AutoHotkey Guide thread on dual-boxing.com forums.

AutoHotkey Guide

In this thread I am going to describe some simple scripts with AutoHotkey. I am not the best programmer (actually I am not programmer at all ) so if you have better ideas how to make listed scripts better - feel free to make a comment also if you have your own script examples - would be nice to have them posted and added to this guide

To download Autohotkey, please go to [www.autohotkey.com www.autohotkey.com]


First of all, on this page: http://www.autohotkey.com/docs/KeyList.htm you can find all supported by AHK hotkeys and information how to type them (syntax) in scripts so AHK would understand your commands.

Start your script with line:

WinGet, wowid, List, World of Warcraft 

This command allows AHK script to determine open WoW windows. Keep in mind, you can run AHK script at any time, and even modify and reload it while WoW clients are opened.

Okay. Lets start with simple keys - "0", "1",... , "9"

~0:: 
KeyWait, 0, D
#IfWinActive, World of Warcraft 
{
ControlSend,, 0, ahk_id %wowid1% 
ControlSend,, 0, ahk_id %wowid2% 
ControlSend,, 0, ahk_id %wowid3% 
ControlSend,, 0, ahk_id %wowid4% 
ControlSend,, 0, ahk_id %wowid5% 
}
Return 

This script waits untill you press "0" button and then sends "0" key to all listed clients (here - 5 WoW clients).

If you for example dual-boxing, it will be look like:

~0:: 
KeyWait, 0, D
#IfWinActive, World of Warcraft 
{
ControlSend,, 0, ahk_id %wowid1% 
ControlSend,, 0, ahk_id %wowid2% 
}
Return 

More about KeyWait command: http://www.autohotkey.com/docs/KeyWait.htm

And more info about ControlSend: http://www.autohotkey.com/docs/commands/ControlSend.htm

Script for "1" key:

~1:: 
KeyWait, 1, D
#IfWinActive, World of Warcraft 
{
ControlSend,, 1, ahk_id %wowid1% 
ControlSend,, 1, ahk_id %wowid2% 
ControlSend,, 1, ahk_id %wowid3% 
ControlSend,, 1, ahk_id %wowid4% 
ControlSend,, 1, ahk_id %wowid5% 
}
Return 

I believe you can assign other keys by yourself. So lets try to work with other keys on your keyboard

Now, lets assign some letters.

Actually, it is as simple as the scripts we have done before. Let's try "F" letter:

~F:: 
#IfWinActive, World of Warcraft 
KeyWait, F, D
{
ControlSend,, F, ahk_id %wowid1% 
ControlSend,, F, ahk_id %wowid2% 
ControlSend,, F, ahk_id %wowid3% 
ControlSend,, F, ahk_id %wowid4% 
ControlSend,, F, ahk_id %wowid5% 
}
Return 

Almost the same as script with number, right?

Here is the script with "E" key for dual-boxing:

~E:: 
KeyWait, E, D
#IfWinActive, World of Warcraft 
{
ControlSend,, E, ahk_id %wowid1% 
ControlSend,, E, ahk_id %wowid2% 
}
Return 

I hope it works for you, so now lets try to send our Numpad keyboard commands.

AHK allows to work with Numpad keys like "Numpad 1", "Numpad 2", Numpad +" etc. It also allows to work with "Numpad Left", "Numpad Home" etc. keys. You can see more info about it at http://www.autohotkey.com/docs/KeyList.htm page.

Here's example with Numpad 1 key:

Numpad1:: 
KeyWait, Numpad1, D
#IfWinActive, World of Warcraft 
{
ControlSend,, {Numpad1 down}{Numpad1 up}, ahk_id %wowid1% 
ControlSend,, {Numpad1 down}{Numpad1 up}, ahk_id %wowid2% 
ControlSend,, {Numpad1 down}{Numpad1 up}, ahk_id %wowid3% 
ControlSend,, {Numpad1 down}{Numpad1 up}, ahk_id %wowid4% 
ControlSend,, {Numpad1 down}{Numpad1 up}, ahk_id %wowid5% 
}
Return 

And here's example with "Numpad -" key:

NumpadSub:: 
KeyWait, NumpadSub, D
#IfWinActive, World of Warcraft 
{
ControlSend,, {NumpadSub down}{NumpadSub up}, ahk_id %wowid1% 
ControlSend,, {NumpadSub down}{NumpadSub up}, ahk_id %wowid2% 
ControlSend,, {NumpadSub down}{NumpadSub up}, ahk_id %wowid3% 
ControlSend,, {NumpadSub down}{NumpadSub up}, ahk_id %wowid4% 
ControlSend,, {NumpadSub down}{NumpadSub up}, ahk_id %wowid5% 
}
Return 

Cool. Lets try F1-F12 keys.

Example with F1 key:

#IfWinActive, World of Warcraft 
F1::
{

ControlSend,,{F1 down}{F1 up}, ahk_id %wowid1% 
ControlSend,,{F1 down}{F1 up}, ahk_id %wowid2% 
ControlSend,,{F1 down}{F1 up}, ahk_id %wowid3% 
ControlSend,,{F1 down}{F1 up}, ahk_id %wowid4% 
ControlSend,,{F1 down}{F1 up}, ahk_id %wowid5% 
}
return

And F5, I hope you can make scripts for others by yourself

#IfWinActive, World of Warcraft 
F5:: 
{
ControlSend,,{F5 down}{F5 up}, ahk_id %wowid1% 
ControlSend,,{F5 down}{F5 up}, ahk_id %wowid2% 
ControlSend,,{F5 down}{F5 up}, ahk_id %wowid3% 
ControlSend,,{F5 down}{F5 up}, ahk_id %wowid4% 
ControlSend,,{F5 down}{F5 up}, ahk_id %wowid5% 
}
return

Nice. Also you can combine your Shift, Alt etc. modifiers with other keyboad keys. For example:

Shift & 1:: 
KeyWait, shift, D 
#IfWinActive, World of Warcraft 
{
ControlSend,,{shift down}{1 down}{1 up}{shift up}, ahk_id %wowid1% 
ControlSend,,{shift down}{1 down}{1 up}{shift up}, ahk_id %wowid2% 
ControlSend,,{shift down}{1 down}{1 up}{shift up}, ahk_id %wowid3% 
ControlSend,,{shift down}{1 down}{1 up}{shift up}, ahk_id %wowid4% 
ControlSend,,{shift down}{1 down}{1 up}{shift up}, ahk_id %wowid5% 
}
return 

Keep in mind, you can use keys Shift, Control, Alt, Win button and also you are not limited with only those keys, you can use keys like RShift (right Shift), RAlt (right alt) etc. And of course LControl, LAlt etc. For more info check Autohotkey documentation.

A few useful things. AKH allows you to remap keys. Myself I have found useful to remap CapsLock key with Control. On my keyboard it is easier to press CapsLock instead of Control. And it looks like:

Capslock::Ctrl

More info about remapping you can find there: http://www.autohotkey.com/docs/misc/Remap.htm

"Spread Out" macro. This is the only way I have found to do the "spread out" thing.

$J:: 
KeyWait, J, D
#IfWinActive, World of Warcraft 
SetKeyDelay, -1
{
ControlSend,, {J down}, ahk_id %wowid1% 
ControlSend,, {J down}, ahk_id %wowid2% 
ControlSend,, {J down}, ahk_id %wowid3% 
ControlSend,, {J down}, ahk_id %wowid4% 
ControlSend,, {J down}, ahk_id %wowid5% 
Sleep, 400
ControlSend,, {J up}, ahk_id %wowid1% 
ControlSend,, {J up}, ahk_id %wowid2% 
ControlSend,, {J up}, ahk_id %wowid3% 
ControlSend,, {J up}, ahk_id %wowid4% 
ControlSend,, {J up}, ahk_id %wowid5% 
}
Return 

For me it is assigned on "J" key. Of course you can change it for any key you like more. Also I have binded on "J" button on different clients different movements. For me it is:

Client1 (main) - nothing. Client2 - strafe left. Client3 - strafe right. Client4 - move forward. Client5 - move backwards.

Lets talk a little about this command:

Sleep, 400

In my "spread out" script when I press "J" my alts are starting to move at sides. Script tells all windows that "J" button is pressed and is holding down. Then script "meets" command "Sleep, 400", which basically means that script waits 400 ms untill executing following lines. After waiting 400 ms, script releases "J" button and characters stop moving. This script with timing is good if you have not super-good latency for all clients and it is good if you want fixed distance of moving for all times

Here is another script for "spread out" movement. You can also use it with WASD (or whatever movements keys you are using). This script is the same as you press button, hold on as long as you want, then release.

~j:: 
#IfWinActive, World of Warcraft 
{
ControlSend, , {j Down}, ahk_id %wowid1% 
ControlSend, , {j Down}, ahk_id %wowid2% 
ControlSend, , {j Down}, ahk_id %wowid3% 
ControlSend, , {j Down}, ahk_id %wowid4% 
}
Return

~j Up:: 
#IfWinActive, World of Warcraft 
{
ControlSend, , {j Up}, ahk_id %wowid1%
ControlSend, , {j Up}, ahk_id %wowid2%
ControlSend, , {j Up}, ahk_id %wowid3%
ControlSend, , {j Up}, ahk_id %wowid4%
}
Return

There is one known defect in all my scripts. All pressed keys are being send to all windows and you cant for example press on Client1 "B" key and key "C" will be received by Client2. Good thing, there is nice person - Sorn - who works on it. Actually, he has done such script for dual-boxing. The scripts asks you to determine main and clone windows. I hope he will make the same for 3-5 boxing.

Note: I have no idea why does he use {= down}{= up} in his scripts, there must be a reason

Note: I believe the Sorn has the equal key (=) mapped on his clone's WoW client to /assist his main so whenever you press a button it will assist off the main window first

As indicated here

#IfWinActive, World of Warcraft 
; *** Makes wow2 Assist Wow1 Player *** 
^=:: 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
return 

Here is his entire script:

; 
; Wow Dual Account Helper Version: .02a 
; Language: English 
; Platform: AutoHotkey Script 
; Author: Sorn 
; NOTES: Written for the Dual-Boxing.com forums, Send PM or post in the Autohotkey thread for assistance or suggestions 
; 
; Script Function: 
; Allows you to play two copies of WOW at the same time 
; 

;Tell user what is about to happen 
SplashTextOn, 325, , Preparing to find your Main and Clone windows of WoW. 
Sleep, 2000 
SplasHtextoff 

;Grab unique window ID's 
WinGet, wowid, List, World of Warcraft 

; Minimize All WOW windows 
WinMinimize, ahk_id %wowid1% 
WinMinimize, ahk_id %wowid2% 

;Determine Main and Clone Windows 
WinActivate, ahk_id %wowid1% 

MsgBox, 4,, Is this your WOW Main window? (press Yes or No) 
IfMsgBox Yes 
idMain = %wowid1% 
else 
idMain = %wowid2% 

If idMain = %wowid1% 
{ 
idClone = %wowid2% 
} else { 
idClone = %wowid1% 
} 

;Activate All WOW windows 
WinActivate, ahk_id %idMain% 
WinActivate, ahk_id %idClone% 


;*** Special Functions *** 

#IfWinActive, World of Warcraft 
; *** Makes wow2 follow Wow1 Player *** 
^-:: 
ControlSend,,{- down}{- up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
; *** Makes wow2 Assist Wow1 Player *** 
^=:: 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
return 

; ******************* 
; *** Hotbars 1-0 *** 
; ******************* 
#IfWinActive, World of Warcraft 
~1:: 
ControlSend,,{1 down}{1 up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{1 down}{1 up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~2:: 
ControlSend,,{2 down}{2 up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{2 down}{2 up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~3:: 
ControlSend,,{3 down}{3 up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{3 down}{3 up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~4:: 
ControlSend,,{4 down}{4 up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{4 down}{4 up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~5:: 
ControlSend,,{5 down}{5 up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{5 down}{5 up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~6:: 
ControlSend,,{6 down}{6 up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{6 down}{6 up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~7:: 
ControlSend,,{7 down}{7 up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{7 down}{7 up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~8:: 
ControlSend,,{8 down}{8 up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{8 down}{8 up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~9:: 
ControlSend,,{9 down}{9 up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{9 down}{9 up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~0:: 
ControlSend,,{0 down}{0 up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{0 down}{0 up}, ahk_id %idClone% 
return 



; *************************** 
; *** Hotbars Shift ^ 1-0 *** 
; *************************** 
#IfWinActive, World of Warcraft 
~+1:: 
ControlSend,,{Shift down}{1 down}{1 up}{Shift up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Shift down}{1 down}{1 up}{Shift up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~+2:: 
ControlSend,,{Shift down}{2 down}{2 up}{Shift up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Shift down}{2 down}{2 up}{Shift up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~+3:: 
ControlSend,,{Shift down}{3 down}{3 up}{Shift up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Shift down}{3 down}{3 up}{Shift up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~+4:: 
ControlSend,,{Shift down}{4 down}{4 up}{Shift up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Shift down}{4 down}{4 up}{Shift up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~+5:: 
ControlSend,,{Shift down}{5 down}{5 up}{Shift up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Shift down}{5 down}{5 up}{Shift up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~+6:: 
ControlSend,,{Shift down}{6 down}{6 up}{Shift up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Shift down}{6 down}{6 up}{Shift up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~+7:: 
ControlSend,,{Shift down}{7 down}{7 up}{Shift up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Shift down}{7 down}{7 up}{Shift up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~+8:: 
ControlSend,,{Shift down}{8 down}{8 up}{Shift up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Shift down}{8 down}{8 up}{Shift up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~+9:: 
ControlSend,,{Shift down}{9 down}{9 up}{Shift up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Shift down}{9 down}{9 up}{Shift up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~+0:: 
ControlSend,,{Shift down}{0 down}{0 up}{Shift up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Shift down}{0 down}{0 up}{Shift up}, ahk_id %idClone% 
return 

; ************************** 
; *** Hotbars Cntl ^ 1-0 *** 
; ************************** 
#IfWinActive, World of Warcraft 
~^1:: 
ControlSend,,{Ctrl down}{1 down}{1 up}{Ctrl up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Ctrl down}{1 down}{1 up}{Ctrl up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~^2:: 
ControlSend,,{Ctrl down}{2 down}{2 up}{Ctrl up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Ctrl down}{2 down}{2 up}{Ctrl up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~^3:: 
ControlSend,,{Ctrl down}{3 down}{3 up}{Ctrl up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Ctrl down}{3 down}{3 up}{Ctrl up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~^4:: 
ControlSend,,{Ctrl down}{4 down}{4 up}{Ctrl up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Ctrl down}{4 down}{4 up}{Ctrl up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~^5:: 
ControlSend,,{Ctrl down}{5 down}{5 up}{Ctrl up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Ctrl down}{5 down}{5 up}{Ctrl up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~^6:: 
ControlSend,,{Ctrl down}{6 down}{6 up}{Ctrl up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Ctrl down}{6 down}{6 up}{Ctrl up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~^7:: 
ControlSend,,{Ctrl down}{7 down}{7 up}{Ctrl up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Ctrl down}{7 down}{7 up}{Ctrl up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~^8:: 
ControlSend,,{Ctrl down}{8 down}{8 up}{Ctrl up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Ctrl down}{8 down}{8 up}{Ctrl up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~^9:: 
ControlSend,,{Ctrl down}{9 down}{9 up}{Ctrl up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Ctrl down}{9 down}{9 up}{Ctrl up}, ahk_id %idClone% 
return 

#IfWinActive, World of Warcraft 
~^0:: 
ControlSend,,{Ctrl down}{0 down}{0 up}{Ctrl up}, ahk_id %idMain% 
ControlSend,,{= down}{= up}, ahk_id %idClone% 
ControlSend,,{Ctrl down}{0 down}{0 up}{Ctrl up}, ahk_id %idClone% 
return
Personal tools