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]
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]