Jump to content


Need help with coding for modifier keys (shift, alt, ctrl)


  • Please log in to reply
3 replies to this topic

#1 PandaCan

PandaCan
  • Guests

Posted 10 September 2012 - 07:13 AM

Hi I'm trying to make a simple world of warcraft keyclone 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, 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)

WinGet, wowid, List, World of Warcraft 

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

WinGet, wowid, List, World of Warcraft 

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

WinGet, wowid, List, World of Warcraft 

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

WinGet, wowid, List, World of Warcraft 

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

WinGet, wowid, List, World of Warcraft 

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

WinGet, wowid, List, World of Warcraft 

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

WinGet, wowid, list, World of Warcraft 

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

WinGet, wowid, list, World of Warcraft 

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

WinGet, wowid, list, World of Warcraft 

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

WinGet, wowid, list, World of Warcraft 

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

WinGet, wowid, List, World of Warcraft 

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

WinGet, wowid, list, World of Warcraft 

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

WinGet, wowid, list, World of Warcraft 

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

WinGet, wowid, list, World of Warcraft  

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

WinGet, wowid, list, World of Warcraft 

~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

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft 

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

WinGet, wowid, list, World of Warcraft 

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

WinGet, wowid, list, World of Warcraft 

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

WinGet, wowid, list, World of Warcraft 

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

WinGet, wowid, list, World of Warcraft 

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

WinGet, wowid, list, World of Warcraft 

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

WinGet, wowid, list, World of Warcraft 

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

WinGet, wowid, list, World of Warcraft 

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

WinGet, wowid, list, World of Warcraft 

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

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

WinGet, wowid, list, World of Warcraft  

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

WinGet, wowid, list, World of Warcraft  

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

WinGet, wowid, list, World of Warcraft  

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

WinGet, wowid, list, World of Warcraft  

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

WinGet, wowid, list, World of Warcraft  

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

WinGet, wowid, list, World of Warcraft  

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

WinGet, wowid, list, World of Warcraft  

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

WinGet, wowid, list, World of Warcraft  

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

WinGet, wowid, list, World of Warcraft  

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

WinGet, wowid, list, World of Warcraft  

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft


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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft

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

WinGet, wowid, list, World of Warcraft





  



Also feel free to criticize on any unnecessary code I have in there I'm sure there is a lot =)

do not post 'game' request/script in non-game area
do not post in a new thread, instead post a reply to your previous thread


#2 Wingfat

Wingfat
  • Members
  • 932 posts

Posted 13 September 2012 - 10:53 PM

confused.... you want to press the letter A in WOW and have the letter A sent? why would you need to code that?
I do see your trying to use Control Send.. so is this WOW game not your active window?

I perfer my Returns to be outside of the {} like:
#IfWinActive, World of Warcraft  ;#makes it so the script keys only work in WOW if that is what you want

~1:: 
IfWinActive, World of Warcraft 
{  
ControlSend,, 1, ahk_id %wowid2%
} 
RETURN


#3 GodlyCheese

GodlyCheese
  • Members
  • 593 posts

Posted 14 September 2012 - 12:44 AM

Putting "#IfWinActive, World of Warcraft" is kind of redundant since every Hotkey already checks it, and you have to remember to end the #If expression so non-WoW Hotkeys can be placed under these if need be. My preference is using IfWin commands inside individual Hotkeys, it makes them more portable.

Your issue could simply be that WoW doesn't accept artificially generated Keystrokes. You might be better off just having WoW's window activated and using SendPlay instead of using ControlSend (which I have found to be notoriously unreliable.)

#4 ajibs

ajibs
  • Members
  • 1 posts

Posted 14 September 2012 - 02:53 AM

I am so confused, please be advised still lay in that section .... :)