Log in

View Full Version : Auto Hotkey Dual Box Code



samhaine
07-06-2007, 09:39 PM
I decided to mess around with AHK for a bit and see if it would work for me. I still haven’t decided if it is the way I want to go, but I have noticed there isn’t any really complete scripts out there that did what I wanted it to do so I played around with it for a few hours and came up with a script that I think is a good baseline for anyone and I thought I would share it with the board.

My goal with this script was to be able to play either character as the main and send the alternate keys to the second window, while retaining all the original functionality I had with each toon when I was single boxing. Something about spamming unneeded keystrokes to both clients when those keystrokes weren’t needed just seemed a bit sloppy to me.

Backspace switches, which window is main and which is secondary. F1- F12 keys are sent to whichever window is secondary allowing you to switch your main and secondary with the press of one button.

If there is an interest in this script I will update this thread as I go.

[code:1]
;; **********************
;; ******* GLOBALS ******
;; **********************

I_Icon =
SetTitleMatchMode, 3
WinGet, wowid, list, World of Warcraft

;;************************************************
;;****** SWAP WINDOW FOCUS USING BACKSPACE *******
;;************************************************

BS::
KeyWait, BS, D
WinGet, Active_Window, ID, A
If Active_Window =%wowid1%
{
WinActivate, ahk_id %wowid2%
}
Else If Active_Window =%wowid2%
{
WinActivate, ahk_id %wowid1%
}
Return

;;********************************************
;;****** SEND FKEYS TO UNFOCUSED WOWID *******
;;********************************************

;****** F1 Key ******

F1::
KeyWait, F1, D
WinGet, Active_Window, ID, A
If Active_Window =%wowid1%
{
ControlSend,, {F1}, ahk_id %wowid2%
}
Else If Active_Window =%wowid2%
{
ControlSend,, {F1}, ahk_id %wowid1%
}
Return

;****** F2 Key ******

F2::
KeyWait, F2, D
WinGet, Active_Window, ID, A
If Active_Window =%wowid1%
{
ControlSend,, {F2}, ahk_id %wowid2%
}
Else If Active_Window =%wowid2%
{
ControlSend,, {F2}, ahk_id %wowid1%
}
Return

;****** F3 Key ******

F3::
KeyWait, F3, D
WinGet, Active_Window, ID, A
If Active_Window =%wowid1%
{
ControlSend,, {F3}, ahk_id %wowid2%
}
Else If Active_Window =%wowid2%
{
ControlSend,, {F3}, ahk_id %wowid1%
}
Return

;****** F4 Key ******

F4::
KeyWait, F4, D
WinGet, Active_Window, ID, A
If Active_Window =%wowid1%
{
ControlSend,, {F4}, ahk_id %wowid2%
}
Else If Active_Window =%wowid2%
{
ControlSend,, {F4}, ahk_id %wowid1%
}
Return

;****** F5 Key ******

F5::
KeyWait, F5, D
WinGet, Active_Window, ID, A
If Active_Window =%wowid1%
{
ControlSend,, {F5}, ahk_id %wowid2%
}
Else If Active_Window =%wowid2%
{
ControlSend,, {F5}, ahk_id %wowid1%
}
Return

;****** F6 Key ******

F6::
KeyWait, F6, D
WinGet, Active_Window, ID, A
If Active_Window =%wowid1%
{
ControlSend,, {F6}, ahk_id %wowid2%
}
Else If Active_Window =%wowid2%
{
ControlSend,, {F6}, ahk_id %wowid1%
}
Return

;****** F7 Key ******

F7::
KeyWait, F7, D
WinGet, Active_Window, ID, A
If Active_Window =%wowid1%
{
ControlSend,, {F7}, ahk_id %wowid2%
}
Else If Active_Window =%wowid2%
{
ControlSend,, {F7}, ahk_id %wowid1%
}
Return

;****** F8 Key ******

F8::
KeyWait, F8, D
WinGet, Active_Window, ID, A
If Active_Window =%wowid1%
{
ControlSend,, {F8}, ahk_id %wowid2%
}
Else If Active_Window =%wowid2%
{
ControlSend,, {F8}, ahk_id %wowid1%
}
Return

;****** F9 Key ******

F9::
KeyWait, F9, D
WinGet, Active_Window, ID, A
If Active_Window =%wowid1%
{
ControlSend,, {F9}, ahk_id %wowid2%
}
Else If Active_Window =%wowid2%
{
ControlSend,, {F9}, ahk_id %wowid1%
}
Return

;****** F10 Key ******

F10::
KeyWait, F10, D
WinGet, Active_Window, ID, A
If Active_Window =%wowid1%
{
ControlSend,, {F10}, ahk_id %wowid2%
}
Else If Active_Window =%wowid2%
{
ControlSend,, {F10}, ahk_id %wowid1%
}
Return

;****** F11 Key ******

F11::
KeyWait, F11, D
WinGet, Active_Window, ID, A
If Active_Window =%wowid1%
{
ControlSend,, {F11}, ahk_id %wowid2%
}
Else If Active_Window =%wowid2%
{
ControlSend,, {F11}, ahk_id %wowid1%
}
Return

;****** F12 Key ******

F12::
KeyWait, F12, D
WinGet, Active_Window, ID, A
If Active_Window =%wowid1%
{
ControlSend,, {F12}, ahk_id %wowid2%
}
Else If Active_Window =%wowid2%
{
ControlSend,, {F12}, ahk_id %wowid1%
}
Return[/code:1]

Boss
07-06-2007, 11:10 PM
very nice I was always going to make a full script but just went the hardware route now. Hope to see you do more with this great start though and keep sharing I have posted my little script><

proxymatic
07-06-2007, 11:42 PM
I'm pretty sure I'm reiterating what you said, but I want to be sure...

So wait, using this I could "control" one of my chars and then using F1-F12 control a second character, if the hotbar was set up correctly? Then use back space to change which character you're controlling (which window you're controlling rather..), then can use F1-F12 to control the other one?

Boss
07-06-2007, 11:46 PM
I'm pretty sure I'm reiterating what you said, but I want to be sure...

So wait, using this I could "control" one of my chars and then using F1-F12 control a second character, if the hotbar was set up correctly? Then use back space to change which character you're controlling (which window you're controlling rather..), then can use F1-F12 to control the other one?

What he has done is when your active wow is up then F1-F12 key presses are going to go only to the second WoW unlike most scripts that send one key press to both wows. When he switches to the second wow so its active the F keys are only going to go to that first wow then. Did I help any? lol

samhaine
07-07-2007, 03:36 AM
Yes, you guys got it,

The concept I’m going for is if I am playing two toons A and B then I have the same set of primary and secondary commands for each, but each A and B only receives the commands I need them to. Example

If im focused on A (by using backspace or clicking on it or simply using ALT+TAB)
My normal keybinds work:
Wasdfqe are my movement keybinds
1,2,3,4,5,6,7,8,9,0,-,= are my 12 main combat bar keybinds
f1-f12 do nothing on this toon, they send commands to keybinds on another bar on toon B

If I am focused on B (by using backspace or clicking on it or simply using ALT+TAB)
My normal keybinds work:
Wasdfqe are my movement keybinds
1,2,3,4,5,6,7,8,9,0,-,= are my 12 main combat bar keybinds
f1-f12 do nothing on this toon, they send commands to keybinds on another bar on toon A

proxymatic
07-07-2007, 01:09 PM
This works great, thanks, I'm working on a variation of it to fit my needs. But my only problem is that I don't know how to send the input to both WoW windows, if one is active and one isn't.

This is probably a really simple answer and I'm just overthinking it, but any help would be appreciated.

overkil2
07-07-2007, 08:18 PM
That code is nice, but I have a question. How do i set up the global for EQ2?

Is it possible?

Runiat
07-07-2007, 08:50 PM
This works great, thanks, I'm working on a variation of it to fit my needs. But my only problem is that I don't know how to send the input to both WoW windows, if one is active and one isn't.

This is probably a really simple answer and I'm just overthinking it, but any help would be appreciated.
Skip the "if"s.

Like this (stolen from Ellay's thread on the topic (http://www.dual-boxing.com/forums2/viewtopic.php?t=17)):
[code:1]~2::
KeyWait 2
IfWinActive, World of Warcraft
{
ControlSend,, 2, ahk_id %wowid1%
ControlSend,, 2, ahk_id %wowid2%
Return
}[/code:1]

Anyway I think I'll try to set this up for my G-keys.. anyone know if anything will happen if I have it hold down a couple of modifiers at the same time as hitting F-keys? I mean I know about alt+F4 but just wether ctrl or shift did something that might slow down my play.

daemonic666
07-11-2007, 10:01 AM
Yesterday night i read your code and was very inspired.

Installed autokey and created 2 new toons to try it.I have a 22' wide monitor so i can keep two wow 800x600 windows on screen.This works really good for me.

Only have 1 little very noobish question : to use F1-F12 keys i think you have to unbind those keys in both wow accounts right ? How do you unbind em without binding another key ?

Thanks a lot

Otlecs
07-11-2007, 10:45 AM
There's a button right there in the Key Binding UI, at the bottom. I'm working just now so can't check the exact wording, but it's pretty unambiguous once you spot it :)

daemonic666
07-11-2007, 10:55 AM
Lol thanks i will check asap.I'm at work too :)

Btw i started with imo the easiest combo,warrior + priest. No distance problems and no multiple dots.Just warrior attack + priest dot+wand or heal.Simple.

Runiat
07-11-2007, 05:58 PM
Simple.
And slow.