Log in

View Full Version : [AutoHotKey] Scripting with AutoHotkey (would like some help)



PandaCan
09-10-2012, 03:43 AM
Hi I'm trying to make a simple world of warcraft keycloning script that clones every key on the board (mostly) as well as modifier keys (shift, alt, ctrl). I'm currently having the hardest time figuring out how to use modifiers with this script. Baically I would like to be able to use all letters a-z and numbers 0-9 as well as mouse button 4 and 5 with each modifier. I don't know if I can simply put the modifier key into the code and put each other key separately or if i have to combine them in each instance, for example shift-a would translate into A in both windows.

Here is my current script for the modifier keys, at the present time it works only to make the main window be affected by modifiers (I hold shift and press R and the main window types it but the off window times absolutely nothing)

I'll also attach my full script (since it is too long)


~LShift:: KeyWait,LShift, D
{
ControlSend,, {LShift}, ahk_id %wowid1%
ControlSend,, {LShift}, ahk_id %wowid2%
Return
}


WinGet, wowid, list, World of Warcraft


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


WinGet, wowid, list, World of Warcraft


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



WinGet, wowid, list, World of Warcraft

Also if anyone knows the code for the tilde key ( ~ ) as well as mouse button 4 and mouse button 5 that would be grand!

Cptan
09-10-2012, 10:22 PM
You can lookup AHK help file Contents->Hotkeys for usage of modifiers.

For example,

To use more than one modifier with a hotkey, list them consecutively (the order does not matter). The following example uses ^!s to indicate Control+Alt+S:


^!s::Send Sincerely,{enter}John Smith ; This line sends keystrokes to the active (foremost) window.return

For R and Shift-R, I will include the following codes


~R:: ..... ; R

~+R:: .... ; shift R

Can't you use ` hotkey instead of ~ ?

Button 4 & 5? Not sure, but you can look under KeyList. I found XButton1 and XButton2.

BTW, there is a gaming forum under AHK site. You may have more lucks over there.

aasi888
09-15-2012, 10:29 AM
This would probably work for Shift + R hotkey.


~+R::
KeyWait,R, D ;optional
{
ControlSend,, {LShift down}{r}{LShift up}, ahk_id %wowid1%
ControlSend,, {LShift down}{r}{LShift up}, ahk_id %wowid2%
}
Return



For mouseclicks I personally use the mouse software to re-direct it to a new hotkey. e.g Mousebutton4 -> CTRL+DEL. Then I just make a script for ^DEL:: in AHK.