The game does it itself, script only changes into normal keys when pressing enter and returning into modified keys when pressing anything that leaves chat.
Mmm didnt work for me Doesnt shift+enter need to be sent to bring up All chat in 2v2s? Just that reading the script, i cant see it anywhere?
IfWinNotExist Company Of Heroes Run Company Of Heroes
#IfWinActive, Company Of Heroes
!CapsLock:: suspend , off SoundBeep return
^CapsLock:: { suspend , on SoundBeep SoundBeep hotkey, q, kbdhandler, Off hotkey, w, kbdhandler, Off hotkey, e, kbdhandler, Off hotkey, a, kbdhandler, Off hotkey, s, kbdhandler, Off hotkey, d, kbdhandler, Off hotkey, f, kbdhandler, Off hotkey, x, kbdhandler, Off entertoggle = 0 return }
Escape:: ; Enables to escape chat and return to normal mode { if (entertoggle) { entertoggle := !entertoggle Send {Escape} ChatMode(entertoggle) } else { Escape::Escape } return }
LButton:: ; Enables to escape chat and return to normal mode { if (entertoggle) { entertoggle := !entertoggle Send {LButton} ChatMode(entertoggle) } else { LButton::LButton } return }
RButton:: ; Enables to escape chat and return to normal mode { if (entertoggle) { entertoggle := !entertoggle Send {RButton} ChatMode(entertoggle) } else { RButton::RButton } return }
MButton:: ; Enables to escape chat and return to normal mode { if (entertoggle) { entertoggle := !entertoggle Send {MButton} ChatMode(entertoggle) } else { MButton::Backspace } return }
kbdhandler: If (A_ThisHotkey == "q") { Send q } If (A_ThisHotkey == "w") { Send w } If (A_ThisHotkey == "e") { Send e } If (A_ThisHotkey == "a") { Send a } If (A_ThisHotkey == "s") { Send s } If (A_ThisHotkey == "d") { Send d } If (A_ThisHotkey == "f") { Send f } If (A_ThisHotkey == "x") { Send x } If (A_ThisHotkey == "c") { Send c } If (A_ThisHotkey == "+q") { Send Q } If (A_ThisHotkey == "+w") { Send W } If (A_ThisHotkey == "+e") { Send E } If (A_ThisHotkey == "+a") { Send A } If (A_ThisHotkey == "+s") { Send S } If (A_ThisHotkey == "+d") { Send D } If (A_ThisHotkey == "+f") { Send F } If (A_ThisHotkey == "+x") { Send X } If (A_ThisHotkey == "+c") { Send C } return
w::up s::down a::left d::right q::a e::D f::numpad0 x::e c::^c ; to have a shorcut for ping
; MButton::Backspace //already reconfigured
*Enter:: ;Enable chat (Team and all chat) { entertoggle := !entertoggle if getKeyState("shift", "P") { Send +{enter} } else { Send {enter} } ChatMode(entertoggle) } return
*NumpadEnter:: ;Enable chat (Team and all chat) { entertoggle := !entertoggle if getKeyState("shift", "P") { Send +{enter} } else { Send {enter} } ChatMode(entertoggle) } return
ChatMode(entertoggle){ if (entertoggle) { hotkey, q, kbdhandler, On hotkey, w, kbdhandler, On hotkey, e, kbdhandler, On hotkey, a, kbdhandler, On hotkey, s, kbdhandler, On hotkey, d, kbdhandler, On hotkey, f, kbdhandler, On hotkey, x, kbdhandler, On hotkey, c, kbdhandler, On hotkey, +q, kbdhandler, On hotkey, +w, kbdhandler, On hotkey, +e, kbdhandler, On hotkey, +a, kbdhandler, On hotkey, +s, kbdhandler, On hotkey, +d, kbdhandler, On hotkey, +f, kbdhandler, On hotkey, +x, kbdhandler, On hotkey, +c, kbdhandler, On } else{ hotkey, q, kbdhandler, Off hotkey, w, kbdhandler, Off hotkey, e, kbdhandler, Off hotkey, a, kbdhandler, Off hotkey, s, kbdhandler, Off hotkey, d, kbdhandler, Off hotkey, f, kbdhandler, Off hotkey, x, kbdhandler, Off hotkey, c, kbdhandler, Off hotkey, +q, kbdhandler, Off hotkey, +w, kbdhandler, Off hotkey, +e, kbdhandler, Off hotkey, +a, kbdhandler, Off hotkey, +s, kbdhandler, Off hotkey, +d, kbdhandler, Off hotkey, +f, kbdhandler, Off hotkey, +x, kbdhandler, Off hotkey, +c, kbdhandler, Off } return entertoggle }
Ok so I've made some improvements to my old script, with a BIG THANKS going out to Dadinjo for improving the chat function in his script, which I have added to mine.
So the script adds... - Suspend/Resume moved to F7/F8 (So F1 - F6 is free for base selection hotkeys) - Autoreinforce for up to 10 men across multiple squads - R - Lay Mines (M) - Lay Wire (N) - Grenade (T, as no longer used for retreat command) - Repair (Y) - Unload/Exit Building (U) ALSO Snipe for British Recon Squad + - Shift now intergrated into the chat function to allow use of capitals (Improvement by Dadinjo) - Troubles when chating ingame and pressing the keys (escape or mousebutton) resolved (Improvement by Dadinjo) + All the OP's original script hotkeys
Spoiler:Crumpets Autohotkey Script v1.1
CODE
SetTitleMatchMode, 2
#IfWinActive, Company Of Heroes F8:: suspend , off SoundBeep return F7:: { suspend , on SoundBeep, 1750, 800
hotkey, w, kbdhandler, Off hotkey, a, kbdhandler, Off hotkey, s, kbdhandler, Off hotkey, d, kbdhandler, Off hotkey, e, kbdhandler, Off hotkey, f, kbdhandler, Off hotkey, q, kbdhandler, Off hotkey, r, kbdhandler, Off hotkey, t, kbdhandler, Off hotkey, m, kbdhandler, Off hotkey, n, kbdhandler, Off hotkey, u, kbdhandler, Off hotkey, y, kbdhandler, Off hotkey, +w, kbdhandler, Off hotkey, +a, kbdhandler, Off hotkey, +s, kbdhandler, Off hotkey, +d, kbdhandler, Off hotkey, +e, kbdhandler, Off hotkey, +f, kbdhandler, Off hotkey, +q, kbdhandler, Off hotkey, +r, kbdhandler, Off hotkey, +t, kbdhandler, Off hotkey, +m, kbdhandler, Off hotkey, +n, kbdhandler, Off hotkey, +u, kbdhandler, Off hotkey, +y, kbdhandler, Off entertoggle = 0 return }
y::e;Repair u::d;Unload t::n;Grenade q::Numpad0;Tac Map e::t;Retreat w::up a::left s::down d::right f::a;Attack move ~:: { SoundBeep hotkey, w, kbdhandler, Off hotkey, a, kbdhandler, Off hotkey, s, kbdhandler, Off hotkey, d, kbdhandler, Off hotkey, e, kbdhandler, Off hotkey, f, kbdhandler, Off hotkey, q, kbdhandler, Off hotkey, r, kbdhandler, Off hotkey, t, kbdhandler, Off hotkey, m, kbdhandler, Off hotkey, n, kbdhandler, Off hotkey, u, kbdhandler, Off hotkey, y, kbdhandler, Off hotkey, +w, kbdhandler, Off hotkey, +a, kbdhandler, Off hotkey, +s, kbdhandler, Off hotkey, +d, kbdhandler, Off hotkey, +e, kbdhandler, Off hotkey, +f, kbdhandler, Off hotkey, +q, kbdhandler, Off hotkey, +r, kbdhandler, Off hotkey, +t, kbdhandler, Off hotkey, +m, kbdhandler, Off hotkey, +n, kbdhandler, Off hotkey, +u, kbdhandler, Off hotkey, +y, kbdhandler, Off entertoggle = 0 }
Escape::; Enables to escape chat and return to normal mode { if (entertoggle) { entertoggle := !entertoggle Send {Escape} hotkey, w, kbdhandler, Off hotkey, a, kbdhandler, Off hotkey, s, kbdhandler, Off hotkey, d, kbdhandler, Off hotkey, e, kbdhandler, Off hotkey, f, kbdhandler, Off hotkey, q, kbdhandler, Off hotkey, r, kbdhandler, Off hotkey, t, kbdhandler, Off hotkey, m, kbdhandler, Off hotkey, n, kbdhandler, Off hotkey, u, kbdhandler, Off hotkey, y, kbdhandler, Off hotkey, +w, kbdhandler, Off hotkey, +a, kbdhandler, Off hotkey, +s, kbdhandler, Off hotkey, +d, kbdhandler, Off hotkey, +e, kbdhandler, Off hotkey, +f, kbdhandler, Off hotkey, +q, kbdhandler, Off hotkey, +r, kbdhandler, Off hotkey, +t, kbdhandler, Off hotkey, +m, kbdhandler, Off hotkey, +n, kbdhandler, Off hotkey, +u, kbdhandler, Off hotkey, +y, kbdhandler, Off entertoggle = 0 } else { Escape::Escape } return }
LButton::; Enables to escape chat and return to normal mode { if (entertoggle) { entertoggle := !entertoggle Send {LButton} hotkey, w, kbdhandler, Off hotkey, a, kbdhandler, Off hotkey, s, kbdhandler, Off hotkey, d, kbdhandler, Off hotkey, e, kbdhandler, Off hotkey, f, kbdhandler, Off hotkey, q, kbdhandler, Off hotkey, r, kbdhandler, Off hotkey, t, kbdhandler, Off hotkey, m, kbdhandler, Off hotkey, n, kbdhandler, Off hotkey, u, kbdhandler, Off hotkey, y, kbdhandler, Off hotkey, +w, kbdhandler, Off hotkey, +a, kbdhandler, Off hotkey, +s, kbdhandler, Off hotkey, +d, kbdhandler, Off hotkey, +e, kbdhandler, Off hotkey, +f, kbdhandler, Off hotkey, +q, kbdhandler, Off hotkey, +r, kbdhandler, Off hotkey, +t, kbdhandler, Off hotkey, +m, kbdhandler, Off hotkey, +n, kbdhandler, Off hotkey, +u, kbdhandler, Off hotkey, +y, kbdhandler, Off entertoggle = 0 } else { LButton::LButton } return }
RButton::; Enables to escape chat and return to normal mode { if (entertoggle) { entertoggle := !entertoggle Send {RButton} hotkey, w, kbdhandler, Off hotkey, a, kbdhandler, Off hotkey, s, kbdhandler, Off hotkey, d, kbdhandler, Off hotkey, e, kbdhandler, Off hotkey, f, kbdhandler, Off hotkey, q, kbdhandler, Off hotkey, r, kbdhandler, Off hotkey, t, kbdhandler, Off hotkey, m, kbdhandler, Off hotkey, n, kbdhandler, Off hotkey, u, kbdhandler, Off hotkey, y, kbdhandler, Off hotkey, +w, kbdhandler, Off hotkey, +a, kbdhandler, Off hotkey, +s, kbdhandler, Off hotkey, +d, kbdhandler, Off hotkey, +e, kbdhandler, Off hotkey, +f, kbdhandler, Off hotkey, +q, kbdhandler, Off hotkey, +r, kbdhandler, Off hotkey, +t, kbdhandler, Off hotkey, +m, kbdhandler, Off hotkey, +n, kbdhandler, Off hotkey, +u, kbdhandler, Off hotkey, +y, kbdhandler, Off entertoggle = 0 } else { RButton::RButton } return }
kbdhandler:
If (A_ThisHotkey == "w") { Send w } If (A_ThisHotkey == "a") { Send a } If (A_ThisHotkey == "s") { Send s } If (A_ThisHotkey == "d") { Send d } If (A_ThisHotkey == "q") { Send q } If (A_ThisHotkey == "e") { Send e } If (A_ThisHotkey == "f") { Send f } If (A_ThisHotkey == "r") { Send r } If (A_ThisHotkey == "t") { Send t } If (A_ThisHotkey == "m") { Send m } If (A_ThisHotkey == "n") { Send n } If (A_ThisHotkey == "u") { Send u } If (A_ThisHotkey == "y") { Send y } If (A_ThisHotkey == "+w") { Send W } If (A_ThisHotkey == "+a") { Send A } If (A_ThisHotkey == "+s") { Send S } If (A_ThisHotkey == "+d") { Send D } If (A_ThisHotkey == "+q") { Send Q } If (A_ThisHotkey == "+e") { Send E } If (A_ThisHotkey == "+f") { Send F } If (A_ThisHotkey == "+r") { Send R } If (A_ThisHotkey == "+t") { Send T } If (A_ThisHotkey == "+m") { Send M } If (A_ThisHotkey == "+n") { Send N } If (A_ThisHotkey == "+u") { Send U } If (A_ThisHotkey == "+y") { Send Y }
return
*ENTER UP::;Enable chat (Team and all chat)
entertoggle := !entertoggle
if getKeyState("shift", "P") { Send {shift down}{enter}{shift up}
hotkey, w, kbdhandler, On hotkey, a, kbdhandler, On hotkey, s, kbdhandler, On hotkey, d, kbdhandler, On hotkey, e, kbdhandler, On hotkey, f, kbdhandler, On hotkey, q, kbdhandler, On hotkey, r, kbdhandler, On hotkey, t, kbdhandler, On hotkey, m, kbdhandler, On hotkey, n, kbdhandler, On hotkey, u, kbdhandler, On hotkey, y, kbdhandler, On hotkey, +w, kbdhandler, On hotkey, +a, kbdhandler, On hotkey, +s, kbdhandler, On hotkey, +d, kbdhandler, On hotkey, +e, kbdhandler, On hotkey, +f, kbdhandler, On hotkey, +q, kbdhandler, On hotkey, +r, kbdhandler, On hotkey, +t, kbdhandler, On hotkey, +m, kbdhandler, On hotkey, +n, kbdhandler, On hotkey, +u, kbdhandler, On hotkey, +y, kbdhandler, On }
else { Send {enter}
hotkey, w, kbdhandler, On hotkey, a, kbdhandler, On hotkey, s, kbdhandler, On hotkey, d, kbdhandler, On hotkey, e, kbdhandler, On hotkey, f, kbdhandler, On hotkey, q, kbdhandler, On hotkey, r, kbdhandler, On hotkey, t, kbdhandler, On hotkey, m, kbdhandler, On hotkey, n, kbdhandler, On hotkey, u, kbdhandler, On hotkey, y, kbdhandler, On hotkey, +w, kbdhandler, On hotkey, +a, kbdhandler, On hotkey, +s, kbdhandler, On hotkey, +d, kbdhandler, On hotkey, +e, kbdhandler, On hotkey, +f, kbdhandler, On hotkey, +q, kbdhandler, On hotkey, +r, kbdhandler, On hotkey, +t, kbdhandler, On hotkey, +m, kbdhandler, On hotkey, +n, kbdhandler, On hotkey, +u, kbdhandler, On hotkey, +y, kbdhandler, On }
if (entertoggle) { hotkey, w, kbdhandler, On hotkey, a, kbdhandler, On hotkey, s, kbdhandler, On hotkey, d, kbdhandler, On hotkey, e, kbdhandler, On hotkey, f, kbdhandler, On hotkey, q, kbdhandler, On hotkey, r, kbdhandler, On hotkey, t, kbdhandler, on hotkey, m, kbdhandler, On hotkey, n, kbdhandler, On hotkey, u, kbdhandler, On hotkey, y, kbdhandler, On hotkey, +w, kbdhandler, On hotkey, +a, kbdhandler, On hotkey, +s, kbdhandler, On hotkey, +d, kbdhandler, On hotkey, +e, kbdhandler, On hotkey, +f, kbdhandler, On hotkey, +q, kbdhandler, On hotkey, +r, kbdhandler, On hotkey, +t, kbdhandler, On hotkey, +m, kbdhandler, On hotkey, +n, kbdhandler, On hotkey, +u, kbdhandler, On hotkey, +y, kbdhandler, On }
else { hotkey, w, kbdhandler, Off hotkey, a, kbdhandler, Off hotkey, s, kbdhandler, Off hotkey, d, kbdhandler, Off hotkey, e, kbdhandler, Off hotkey, f, kbdhandler, Off hotkey, q, kbdhandler, Off hotkey, r, kbdhandler, Off hotkey, t, kbdhandler, Off hotkey, m, kbdhandler, Off hotkey, n, kbdhandler, Off hotkey, u, kbdhandler, Off hotkey, y, kbdhandler, Off hotkey, +w, kbdhandler, Off hotkey, +a, kbdhandler, Off hotkey, +s, kbdhandler, Off hotkey, +d, kbdhandler, Off hotkey, +e, kbdhandler, Off hotkey, +f, kbdhandler, Off hotkey, +q, kbdhandler, Off hotkey, +r, kbdhandler, Off hotkey, +t, kbdhandler, Off hotkey, +m, kbdhandler, Off hotkey, +n, kbdhandler, Off hotkey, +u, kbdhandler, Off hotkey, +y, kbdhandler, Off }
$MButton::;Enable Vehicle click-queued movement Send {Rbutton} Send {Shift Down};Delete this line if you don't want 1st click to be priorized. Loop { if not GetKeyState("MButton", "P") break Send {Rbutton}; sleep 20 } Send {Shift Up} return
Everyone is free to use!
*Note* Mousebutton 3 will still cause issues when hit during chat, due to use for Move-Shift Vehicle function (Can't be bothered resolving at this time, as it will rarely happen)
RampageCrumpet, I think this would solve your issue with middlemouse button
Spoiler
$MButton::;Enable Vehicle click-queued movement if (entertoggle) { entertoggle := !entertoggle Send {MButton} hotkey, q, kbdhandler, Off hotkey, w, kbdhandler, Off hotkey, e, kbdhandler, Off hotkey, a, kbdhandler, Off hotkey, s, kbdhandler, Off hotkey, d, kbdhandler, Off hotkey, f, kbdhandler, Off hotkey, x, kbdhandler, Off hotkey, c, kbdhandler, Off hotkey, +q, kbdhandler, Off hotkey, +w, kbdhandler, Off hotkey, +e, kbdhandler, Off hotkey, +a, kbdhandler, Off hotkey, +s, kbdhandler, Off hotkey, +d, kbdhandler, Off hotkey, +f, kbdhandler, Off hotkey, +x, kbdhandler, Off hotkey, +c, kbdhandler, Off } else { Send {Rbutton} Send {Shift Down};Delete this line if you don't want 1st click to be priorized. Loop { if not GetKeyState("MButton", "P") break Send {Rbutton}; sleep 20 } Send {Shift Up} } return
This post has been edited by Dadinjo: Apr 20 2012, 09:31 AM
For the uninitiated in Autohotkey scripts, this is new version of my script without the mousebutton 3 problem! Again a BIG BIG BIG THANKS going out to Dadinjo for helping me improve the chat function once more.
So the script adds... - Suspend/Resume moved to F7/F8 (So F1 - F6 is free for base selection hotkeys) - Autoreinforce for up to 10 men across multiple squads - R - Lay Mines (M) - Lay Wire (N) - Grenade (T, as no longer used for retreat command) - Repair (Y) - Unload/Exit Building (U) ALSO Snipe for British Recon Squad + - Shift now integrated into the chat function to allow use of capitals (Improvement by Dadinjo) - Troubles when chating ingame and pressing the keys (escape or mousebutton) resolved (Improvement by Dadinjo) - Trouble with chating ingame and pressing the middlemouse button (mousebutton 3) resolved (Improvement by Dadinjo) + All the OP's original script hotkeys
Spoiler:Crumpets Autohotkey Script v1.2
CODE
SetTitleMatchMode, 2
#IfWinActive, Company Of Heroes F8:: suspend , off SoundBeep return F7:: { suspend , on SoundBeep, 1750, 800
hotkey, w, kbdhandler, Off hotkey, a, kbdhandler, Off hotkey, s, kbdhandler, Off hotkey, d, kbdhandler, Off hotkey, e, kbdhandler, Off hotkey, f, kbdhandler, Off hotkey, q, kbdhandler, Off hotkey, r, kbdhandler, Off hotkey, t, kbdhandler, Off hotkey, m, kbdhandler, Off hotkey, n, kbdhandler, Off hotkey, u, kbdhandler, Off hotkey, y, kbdhandler, Off hotkey, +w, kbdhandler, Off hotkey, +a, kbdhandler, Off hotkey, +s, kbdhandler, Off hotkey, +d, kbdhandler, Off hotkey, +e, kbdhandler, Off hotkey, +f, kbdhandler, Off hotkey, +q, kbdhandler, Off hotkey, +r, kbdhandler, Off hotkey, +t, kbdhandler, Off hotkey, +m, kbdhandler, Off hotkey, +n, kbdhandler, Off hotkey, +u, kbdhandler, Off hotkey, +y, kbdhandler, Off entertoggle = 0 return }
y::e;Repair u::d;Unload t::n;Grenade q::Numpad0;Tac Map e::t;Retreat w::up a::left s::down d::right f::a;Attack move ~:: { SoundBeep hotkey, w, kbdhandler, Off hotkey, a, kbdhandler, Off hotkey, s, kbdhandler, Off hotkey, d, kbdhandler, Off hotkey, e, kbdhandler, Off hotkey, f, kbdhandler, Off hotkey, q, kbdhandler, Off hotkey, r, kbdhandler, Off hotkey, t, kbdhandler, Off hotkey, m, kbdhandler, Off hotkey, n, kbdhandler, Off hotkey, u, kbdhandler, Off hotkey, y, kbdhandler, Off hotkey, +w, kbdhandler, Off hotkey, +a, kbdhandler, Off hotkey, +s, kbdhandler, Off hotkey, +d, kbdhandler, Off hotkey, +e, kbdhandler, Off hotkey, +f, kbdhandler, Off hotkey, +q, kbdhandler, Off hotkey, +r, kbdhandler, Off hotkey, +t, kbdhandler, Off hotkey, +m, kbdhandler, Off hotkey, +n, kbdhandler, Off hotkey, +u, kbdhandler, Off hotkey, +y, kbdhandler, Off entertoggle = 0 }
Escape::; Enables to escape chat and return to normal mode { if (entertoggle) { entertoggle := !entertoggle Send {Escape} hotkey, w, kbdhandler, Off hotkey, a, kbdhandler, Off hotkey, s, kbdhandler, Off hotkey, d, kbdhandler, Off hotkey, e, kbdhandler, Off hotkey, f, kbdhandler, Off hotkey, q, kbdhandler, Off hotkey, r, kbdhandler, Off hotkey, t, kbdhandler, Off hotkey, m, kbdhandler, Off hotkey, n, kbdhandler, Off hotkey, u, kbdhandler, Off hotkey, y, kbdhandler, Off hotkey, +w, kbdhandler, Off hotkey, +a, kbdhandler, Off hotkey, +s, kbdhandler, Off hotkey, +d, kbdhandler, Off hotkey, +e, kbdhandler, Off hotkey, +f, kbdhandler, Off hotkey, +q, kbdhandler, Off hotkey, +r, kbdhandler, Off hotkey, +t, kbdhandler, Off hotkey, +m, kbdhandler, Off hotkey, +n, kbdhandler, Off hotkey, +u, kbdhandler, Off hotkey, +y, kbdhandler, Off entertoggle = 0 } else { Escape::Escape } return }
LButton::; Enables to escape chat and return to normal mode { if (entertoggle) { entertoggle := !entertoggle Send {LButton} hotkey, w, kbdhandler, Off hotkey, a, kbdhandler, Off hotkey, s, kbdhandler, Off hotkey, d, kbdhandler, Off hotkey, e, kbdhandler, Off hotkey, f, kbdhandler, Off hotkey, q, kbdhandler, Off hotkey, r, kbdhandler, Off hotkey, t, kbdhandler, Off hotkey, m, kbdhandler, Off hotkey, n, kbdhandler, Off hotkey, u, kbdhandler, Off hotkey, y, kbdhandler, Off hotkey, +w, kbdhandler, Off hotkey, +a, kbdhandler, Off hotkey, +s, kbdhandler, Off hotkey, +d, kbdhandler, Off hotkey, +e, kbdhandler, Off hotkey, +f, kbdhandler, Off hotkey, +q, kbdhandler, Off hotkey, +r, kbdhandler, Off hotkey, +t, kbdhandler, Off hotkey, +m, kbdhandler, Off hotkey, +n, kbdhandler, Off hotkey, +u, kbdhandler, Off hotkey, +y, kbdhandler, Off entertoggle = 0 } else { LButton::LButton } return }
RButton::; Enables to escape chat and return to normal mode { if (entertoggle) { entertoggle := !entertoggle Send {RButton} hotkey, w, kbdhandler, Off hotkey, a, kbdhandler, Off hotkey, s, kbdhandler, Off hotkey, d, kbdhandler, Off hotkey, e, kbdhandler, Off hotkey, f, kbdhandler, Off hotkey, q, kbdhandler, Off hotkey, r, kbdhandler, Off hotkey, t, kbdhandler, Off hotkey, m, kbdhandler, Off hotkey, n, kbdhandler, Off hotkey, u, kbdhandler, Off hotkey, y, kbdhandler, Off hotkey, +w, kbdhandler, Off hotkey, +a, kbdhandler, Off hotkey, +s, kbdhandler, Off hotkey, +d, kbdhandler, Off hotkey, +e, kbdhandler, Off hotkey, +f, kbdhandler, Off hotkey, +q, kbdhandler, Off hotkey, +r, kbdhandler, Off hotkey, +t, kbdhandler, Off hotkey, +m, kbdhandler, Off hotkey, +n, kbdhandler, Off hotkey, +u, kbdhandler, Off hotkey, +y, kbdhandler, Off entertoggle = 0 } else { RButton::RButton } return }
kbdhandler:
If (A_ThisHotkey == "w") { Send w } If (A_ThisHotkey == "a") { Send a } If (A_ThisHotkey == "s") { Send s } If (A_ThisHotkey == "d") { Send d } If (A_ThisHotkey == "q") { Send q } If (A_ThisHotkey == "e") { Send e } If (A_ThisHotkey == "f") { Send f } If (A_ThisHotkey == "r") { Send r } If (A_ThisHotkey == "t") { Send t } If (A_ThisHotkey == "m") { Send m } If (A_ThisHotkey == "n") { Send n } If (A_ThisHotkey == "u") { Send u } If (A_ThisHotkey == "y") { Send y } If (A_ThisHotkey == "+w") { Send W } If (A_ThisHotkey == "+a") { Send A } If (A_ThisHotkey == "+s") { Send S } If (A_ThisHotkey == "+d") { Send D } If (A_ThisHotkey == "+q") { Send Q } If (A_ThisHotkey == "+e") { Send E } If (A_ThisHotkey == "+f") { Send F } If (A_ThisHotkey == "+r") { Send R } If (A_ThisHotkey == "+t") { Send T } If (A_ThisHotkey == "+m") { Send M } If (A_ThisHotkey == "+n") { Send N } If (A_ThisHotkey == "+u") { Send U } If (A_ThisHotkey == "+y") { Send Y }
return
*ENTER UP::;Enable chat (Team and all chat)
entertoggle := !entertoggle
if getKeyState("shift", "P") { Send {shift down}{enter}{shift up}
hotkey, w, kbdhandler, On hotkey, a, kbdhandler, On hotkey, s, kbdhandler, On hotkey, d, kbdhandler, On hotkey, e, kbdhandler, On hotkey, f, kbdhandler, On hotkey, q, kbdhandler, On hotkey, r, kbdhandler, On hotkey, t, kbdhandler, On hotkey, m, kbdhandler, On hotkey, n, kbdhandler, On hotkey, u, kbdhandler, On hotkey, y, kbdhandler, On hotkey, +w, kbdhandler, On hotkey, +a, kbdhandler, On hotkey, +s, kbdhandler, On hotkey, +d, kbdhandler, On hotkey, +e, kbdhandler, On hotkey, +f, kbdhandler, On hotkey, +q, kbdhandler, On hotkey, +r, kbdhandler, On hotkey, +t, kbdhandler, On hotkey, +m, kbdhandler, On hotkey, +n, kbdhandler, On hotkey, +u, kbdhandler, On hotkey, +y, kbdhandler, On }
else { Send {enter}
hotkey, w, kbdhandler, On hotkey, a, kbdhandler, On hotkey, s, kbdhandler, On hotkey, d, kbdhandler, On hotkey, e, kbdhandler, On hotkey, f, kbdhandler, On hotkey, q, kbdhandler, On hotkey, r, kbdhandler, On hotkey, t, kbdhandler, On hotkey, m, kbdhandler, On hotkey, n, kbdhandler, On hotkey, u, kbdhandler, On hotkey, y, kbdhandler, On hotkey, +w, kbdhandler, On hotkey, +a, kbdhandler, On hotkey, +s, kbdhandler, On hotkey, +d, kbdhandler, On hotkey, +e, kbdhandler, On hotkey, +f, kbdhandler, On hotkey, +q, kbdhandler, On hotkey, +r, kbdhandler, On hotkey, +t, kbdhandler, On hotkey, +m, kbdhandler, On hotkey, +n, kbdhandler, On hotkey, +u, kbdhandler, On hotkey, +y, kbdhandler, On }
if (entertoggle) { hotkey, w, kbdhandler, On hotkey, a, kbdhandler, On hotkey, s, kbdhandler, On hotkey, d, kbdhandler, On hotkey, e, kbdhandler, On hotkey, f, kbdhandler, On hotkey, q, kbdhandler, On hotkey, r, kbdhandler, On hotkey, t, kbdhandler, on hotkey, m, kbdhandler, On hotkey, n, kbdhandler, On hotkey, u, kbdhandler, On hotkey, y, kbdhandler, On hotkey, +w, kbdhandler, On hotkey, +a, kbdhandler, On hotkey, +s, kbdhandler, On hotkey, +d, kbdhandler, On hotkey, +e, kbdhandler, On hotkey, +f, kbdhandler, On hotkey, +q, kbdhandler, On hotkey, +r, kbdhandler, On hotkey, +t, kbdhandler, On hotkey, +m, kbdhandler, On hotkey, +n, kbdhandler, On hotkey, +u, kbdhandler, On hotkey, +y, kbdhandler, On }
else { hotkey, w, kbdhandler, Off hotkey, a, kbdhandler, Off hotkey, s, kbdhandler, Off hotkey, d, kbdhandler, Off hotkey, e, kbdhandler, Off hotkey, f, kbdhandler, Off hotkey, q, kbdhandler, Off hotkey, r, kbdhandler, Off hotkey, t, kbdhandler, Off hotkey, m, kbdhandler, Off hotkey, n, kbdhandler, Off hotkey, u, kbdhandler, Off hotkey, y, kbdhandler, Off hotkey, +w, kbdhandler, Off hotkey, +a, kbdhandler, Off hotkey, +s, kbdhandler, Off hotkey, +d, kbdhandler, Off hotkey, +e, kbdhandler, Off hotkey, +f, kbdhandler, Off hotkey, +q, kbdhandler, Off hotkey, +r, kbdhandler, Off hotkey, +t, kbdhandler, Off hotkey, +m, kbdhandler, Off hotkey, +n, kbdhandler, Off hotkey, +u, kbdhandler, Off hotkey, +y, kbdhandler, Off }
$MButton::;Enable Vehicle click-queued movement if (entertoggle) { entertoggle := !entertoggle Send {MButton} hotkey, w, kbdhandler, Off hotkey, a, kbdhandler, Off hotkey, s, kbdhandler, Off hotkey, d, kbdhandler, Off hotkey, e, kbdhandler, Off hotkey, f, kbdhandler, Off hotkey, q, kbdhandler, Off hotkey, r, kbdhandler, Off hotkey, t, kbdhandler, Off hotkey, m, kbdhandler, Off hotkey, n, kbdhandler, Off hotkey, u, kbdhandler, Off hotkey, y, kbdhandler, Off hotkey, +w, kbdhandler, Off hotkey, +a, kbdhandler, Off hotkey, +s, kbdhandler, Off hotkey, +d, kbdhandler, Off hotkey, +e, kbdhandler, Off hotkey, +f, kbdhandler, Off hotkey, +q, kbdhandler, Off hotkey, +r, kbdhandler, Off hotkey, +t, kbdhandler, Off hotkey, +m, kbdhandler, Off hotkey, +n, kbdhandler, Off hotkey, +u, kbdhandler, Off hotkey, +y, kbdhandler, Off entertoggle = 0 } else { Send {Rbutton} Send {Shift Down};Delete this line if you don't want 1st click to be priorized. Loop { if not GetKeyState("MButton", "P") break Send {Rbutton}; sleep 20 } Send {Shift Up} } return
400 lines of code for a simple chat toggle?? Couldn't you use a function or a subroutine? This monstrosity is going to be huge pain for you if you'll ever want to add/remove hotkeys.
Yeah, i know. But hey, it works, so as long as i dont need to change it, we're all good!
But yeah, dear god, ive created a monster
Good work rampageCrumpet. It's very hard to enable chat when the key mapping is different from the original.
It took me 2 days to develop chat code in order to enable 7-8 keys to use in chat.
Adding a subroutine?... you can try it, but remember the script is enabled so your WSAD keys are up,down,left,right. you are starting a subroutine when that keys are previously loaded.
I've made another script that uses slightly different approach.
It also solves some more bugs when using chat and pressing not only escape or mouse buttons but pressing those keys with modifiers up (for example pressing shift+mouse button when chatting)
Although script still has over 200 lines, code is not that redundant so you can change one thing in single spot.
Spoiler
SetTitleMatchMode, 2
#IfWinActive, Company Of Heroes
;TURNING THE SCRIPT ON AND OFF !CapsLock:: suspend , off SoundBeep return
^CapsLock:: suspend , on SoundBeep SoundBeep return
;TOGGLE OF THE CHAT *Enter:: { entertoggle := !entertoggle if getKeyState("shift", "P") { SendInput +{enter} } else { SendInput {enter} } return }
*NumpadEnter:: ;NEEDED BECAUSE IF YOU ENTER CHAT WITH ONE ENTER AND EXIT WITH ANOTHER IT SCREWS UP ENTERTOGGLE VALUE { entertoggle := !entertoggle if getKeyState("shift", "P") { SendInput +{enter} } else { SendInput {enter} } return }
Escape:: ;ENABLES TO ESCAPE CHAT AND RETURN TO NORMAL MODE +Escape:: ^Escape:: !Escape:: <^>!Escape:: { if (entertoggle) { entertoggle := !entertoggle SendInput {Escape} } else { Escape::Escape } return }
LButton:: ;ENABLES TO ESCAPE CHAT AND RETURN TO NORMAL MODE +LButton:: ^LButton:: !LButton:: <^>!LButton:: ^!LButton:: ^+LButton:: +!LButton:: ^+!LButton:: { if (entertoggle) { entertoggle := !entertoggle SendInput {LButton} } else { LButton::LButton } return }
RButton:: ;ENABLES TO ESCAPE CHAT AND RETURN TO NORMAL MODE +RButton:: ^RButton:: !RButton:: <^>!RButton:: ^!RButton:: ^+RButton:: +!RButton:: ^+!RButton:: { if (entertoggle) { entertoggle := !entertoggle SendInput {RButton} } else { RButton::RButton } return }
*MButton:: ;ENABLES TO ESCAPE CHAT AND RETURN TO NORMAL MODE { if (entertoggle) { entertoggle := !entertoggle SendInput {MButton} } else { SendInput {Backspace} ;CHANGES MIDDLE MOUSE BUTTON } return }
One bug that still exist though, is when starting script from inside a ingame chat. But I dont see a way to fix that using autohotkeys. It can still be solved easily by stoping and resuming script outside of chat.
This post has been edited by Dadinjo: Apr 21 2012, 13:11 PM
I made a much simpler script. All you have to do is declare what hotkeys you are using and a function will do everything else. Will turn hotkeys on properly when closing chat by mouse click or scroll. Obviously it still has to be manually disabled when chatting in lobby.
Note that I use tons of comments so it's much easier to read in editor which highlights syntax (such as Notepad++).
Colours: Core parts of the script, don't edit those parts Suspend/restart Hotkey declaration part, including instructions User hotkeys
Open spoiler to see code:
Spoiler
;Initialisation #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. Process, Priority, , High
;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ; ChatMode ;Author: Xalard ;Don't touch this part unless you know what you are doing. ; Parameters: ; list1 = mapped keys list ; list2 = hotkeys list ; mode: ; on - hotkeys DISABLED ; off - hotkeys ENABLED ; toggle
ChatOff: ;-needed to toggle chat off on mouse click ChatMode(mapped, hotkeys, "off")
ChatMode(list1, list2, mode = "toggle") { static ; space removal StringReplace, list1, list1, %A_Space%,,All StringReplace, list1, list1, &,%A_Space%&%A_Space%,All ;fix for custom key combinations using & StringReplace, list2, list2, %A_Space%,,All StringReplace, list2, list2, &,%A_Space%&%A_Space%,All ; translate the "mode" argument to one to use with "Hotkey" function and set chat status if mode = toggle { mode_hk = toggle chat := !chat } else if mode = on { mode_hk = off chat := 1 } else if mode = off { mode_hk = on chat := 0 } else MsgBox, %mode% is not a valid parameter for ChatMode function! ; execute all necessary "Hotkey" commands if list2 != "" { loop, parse, list2, `, { Hotkey, %A_LoopField%, %mode_hk% } } if list1 != "" { loop, parse, list1, `, { Hotkey, *%A_LoopField%, %mode_hk% Hotkey, *%A_LoopField% up, %mode_hk% } } ; Prevent mouse from fucking up the script If chat = 0 { Hotkey, ~*LButton, ChatOff, off Hotkey, ~*RButton, ChatOff, off Hotkey, ~*MButton, ChatOff, off Hotkey, ~*WheelUp, ChatOff, off Hotkey, ~*WheelDown, ChatOff, off } Else { Hotkey, ~*LButton, ChatOff, on Hotkey, ~*RButton, ChatOff, on Hotkey, ~*MButton, ChatOff, on Hotkey, ~*WheelUp, ChatOff, on Hotkey, ~*WheelDown, ChatOff, on } } ;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Due to the way AHK handles global variables, hotkeys to toggle for the chat ; compatibilty have to be declared BEFORE the hotkeys themselves are set ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; HOTKEYS ;Declare all hotkeys you want disabled when chatting
; CLOSING CHAT BY USING MOUSE BUTTONS ;This script will still work correctly if you use mouse click or scrollwheel to close the chat ;If you don't declare your mouse hotkeys below, the script might break if you use them when chatting
; Guidelines for listing keys in this section: ; separate keys using a comma , ; modifiers such as in ~*Tab or !BS also have to be listed ; spaces are automatically removed ; if you have no keys to declare, leave the variable blank, eg. mapped := ""
; If you declare a hotkey that doesn't exist, the script will crash when you press Enter
;Declare all REMAPPED keys below: ; Remapped keys are keys that are coded like this: ; w::up ; Space::Numpad0 mapped := "w,a,s,d"
;Declare all other hotkeys below: hotkeys := "+1,+2,+3,+4,+5,+6,MButton,+f,+LAlt"
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;ALL hotkeys must be placed below this line ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F9:: ;always on, in case #IfWinActive refuses to work Suspend Off SoundBeep Reload return
;====================================================== #IfWinActive, Company Of Heroes
;Suspend F11:: SoundBeep, 1750, 800 Suspend On return
;Camera setup Cam: ;Basic camera reset function, remember to use "BlockInput MouseMoveOff" after it { BlockInput MouseMove send {BS} send {BS} MouseClick,WheelDown,,,30,0,D,R } return
;Vehicle click-queue script MButton:: Send {Rbutton} Send {Shift Down} ;Delete this line if you don't want 1st click to be priorized. Loop { if not GetKeyState("MButton", "P") break Send {Rbutton} sleep 20 ;sets delay between clicks } Send {Shift Up} return
return
This post has been edited by Xalard: Apr 21 2012, 15:47 PM
CRUMPETS AUTOHOTKEY SCRIPT v2.0 - (Script by Xalard, Edited by RampageCrumpet)
Ok Ladies and Gentlemen, I've finally had some time to play with Xalards script, and have brought over all the features of my old scripts into the new! A massive thankyou goes out to Xalard for writing this script, and allowing us all to use it!
Script features include... F11/F9 - Suspend/Resume w,a,s,d - Controls Camera Movement CapsLock - Halt q - Tactical Map e - Retreat t - Grenade y - Sticky Bomb u - Unload f - Attack Move h - Hold Fire n - Sandbags m - Mine k - Tank Traps l - Wire r - AutoReinforce (Reinforce multiple selected squads) Shift+Alt - Quick Camera Reset MiddleMouse - Vehicle Click-queue Script (See Video: http://www.youtube.com/watch?v=Hv-n_IbKalI) + Improved Chat - Hotkeys disable during chat, so all you E's don't turn into T's! Plus no more bugs when hitting Esc or MouseButtons either!
CONFUSED? For those who have never used a script before a small Tutorial is included below...
Spoiler:Beginners Tutorial To Autohotkey Scripts
Hi there! Autohotkey is a freely available program that allows its users to configure any key on your keyboard to execute certain commands. In this case, we are using Autohotkey to reconfigure keys for Company of Heroes. For example, changing the w,a,s,d keys to move the camera. This can be one of the ways to improve your micromanagement skills, so you can play the game more efficiently and hopefully win more often!
Autohotkey runs its own special code, called a script, which tells the program what to do, such as my one below. If you would like to use a script to modify your Company of Heroes Hotkeys, you must... 1. Download and Install Autohotkey. You can get it from here at: http://www.autohotkey.com/download/ 2. Copy and Paste the entire script into Notepad on your computer. 3. Go to File > Save As... 4. Select where you would like the script to be saved. 5. In the File Name box, name your script something appropriate, followed by .ahk (E.g. MyScript.ahk) 6. Click Save! When you want to play Company of Heroes, just double click on the Script icon before opening the game. Have fun!
*Note* If you are using a Company of Heroes mod, make sure you right click the script and select Run as Administrator otherwise your script will not work in-game.
THE SCRIPT Copy & Paste...
Spoiler:Crumpets Autohotkey Script v2.0
;Initialisation #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. Process, Priority, , High
;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ; ChatMode ;Author: Xalard ;Don't touch this part unless you know what you are doing. ; Parameters: ; list1 = mapped keys list ; list2 = hotkeys list ; mode: ; on - hotkeys DISABLED ; off - hotkeys ENABLED ; toggle
ChatOff: ;-needed to toggle chat off on mouse click ChatMode(mapped, hotkeys, "off")
ChatMode(list1, list2, mode = "toggle") { static ; space removal StringReplace, list1, list1, %A_Space%,,All StringReplace, list1, list1, &,%A_Space%&%A_Space%,All;fix for custom key combinations using & StringReplace, list2, list2, %A_Space%,,All StringReplace, list2, list2, &,%A_Space%&%A_Space%,All ; translate the "mode" argument to one to use with "Hotkey" function and set chat status if mode = toggle { mode_hk = toggle chat := !chat } else if mode = on { mode_hk = off chat := 1 } else if mode = off { mode_hk = on chat := 0 } else MsgBox, %mode% is not a valid parameter for ChatMode function! ; execute all necessary "Hotkey" commands if list2 != "" { loop, parse, list2, `, { Hotkey, %A_LoopField%, %mode_hk% } } if list1 != "" { loop, parse, list1, `, { Hotkey, *%A_LoopField%, %mode_hk% Hotkey, *%A_LoopField% up, %mode_hk% } } ; Prevent mouse from fucking up the script If chat = 0 { Hotkey, ~*LButton, ChatOff, off Hotkey, ~*RButton, ChatOff, off Hotkey, ~*MButton, ChatOff, off Hotkey, ~*WheelUp, ChatOff, off Hotkey, ~*WheelDown, ChatOff, off } Else { Hotkey, ~*LButton, ChatOff, on Hotkey, ~*RButton, ChatOff, on Hotkey, ~*MButton, ChatOff, on Hotkey, ~*WheelUp, ChatOff, on Hotkey, ~*WheelDown, ChatOff, on } } ;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Due to the way AHK handles global variables, hotkeys to toggle for the chat ; compatibilty have to be declared BEFORE the hotkeys themselves are set ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; HOTKEYS ;Declare all hotkeys you want disabled when chatting
; CLOSING CHAT BY USING MOUSE BUTTONS ;This script will still work correctly if you use mouse click or scrollwheel to close the chat ;If you don't declare your mouse hotkeys below, the script might break if you use them when chatting
; Guidelines for listing keys in this section: ; separate keys using a comma , ; modifiers such as in ~*Tab or !BS also have to be listed ; spaces are automatically removed ; if you have no keys to declare, leave the variable blank, eg. mapped := ""
; If you declare a hotkey that doesn't exist, the script will crash when you press Enter
;Declare all REMAPPED keys below: ; Remapped keys are keys that are coded like this: ; w::up ; Space::Numpad0 mapped := "w,a,s,d,q,e,t,y,u,f,CapsLock,h"
;Declare all other hotkeys below: hotkeys := "MButton,r,n,k,l,m,+LAlt"
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;ALL hotkeys must be placed below this line ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F9:: ;always on, in case #IfWinActive refuses to work Suspend Off SoundBeep Reload return
;====================================================== #IfWinActive, Company Of Heroes
;Suspend F11:: SoundBeep, 1750, 800 Suspend On return
;Basic/Quick Camera Reset Function Setup Cam: ;Basic camera reset function, remember to use "BlockInput MouseMoveOff" after it { BlockInput MouseMove send {BS} send {BS} MouseClick,WheelDown,,,30,0,D,R } return
;Vehicle click-queue script MButton:: Send {Rbutton} Send {Shift Down} ;Delete this line if you don't want 1st click to be priorized. Loop { if not GetKeyState("MButton", "P") break Send {Rbutton} sleep 20 ;sets delay between clicks } Send {Shift Up} return
WANT YOUR OWN UNIQUE HOTKEYS? For those wanting to Modify the above Script or Create their Own Unique Autohotkey Script, but are not sure how, follow the Guide below...
Spoiler:Advanced Tutorial: Modifying Your Script
If you right click on your script, you will see the option edit script in the context menu. Click on the edit script option and it will bring up your scripts code in Notepad. It is from here we can modify the code so Autohotkey does what we want. Don't forget to save your script before exiting, then reload it again to test.
*Note* Keep in mind that every line that begins with a semicolon ; is just for our benefit as a note. These are not executed by Autohotkey.
Now if we Look Again at the Script from Above...
Spoiler
;Initialisation #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. Process, Priority, , High
;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ; ChatMode ;Author: Xalard ;Don't touch this part unless you know what you are doing. ; Parameters: ; list1 = mapped keys list ; list2 = hotkeys list ; mode: ; on - hotkeys DISABLED ; off - hotkeys ENABLED ; toggle
ChatOff: ;-needed to toggle chat off on mouse click ChatMode(mapped, hotkeys, "off")
ChatMode(list1, list2, mode = "toggle") { static ; space removal StringReplace, list1, list1, %A_Space%,,All StringReplace, list1, list1, &,%A_Space%&%A_Space%,All ;fix for custom key combinations using & StringReplace, list2, list2, %A_Space%,,All StringReplace, list2, list2, &,%A_Space%&%A_Space%,All ; translate the "mode" argument to one to use with "Hotkey" function and set chat status if mode = toggle { mode_hk = toggle chat := !chat } else if mode = on { mode_hk = off chat := 1 } else if mode = off { mode_hk = on chat := 0 } else MsgBox, %mode% is not a valid parameter for ChatMode function! ; execute all necessary "Hotkey" commands if list2 != "" { loop, parse, list2, `, { Hotkey, %A_LoopField%, %mode_hk% } } if list1 != "" { loop, parse, list1, `, { Hotkey, *%A_LoopField%, %mode_hk% Hotkey, *%A_LoopField% up, %mode_hk% } } ; Prevent mouse from fucking up the script If chat = 0 { Hotkey, ~*LButton, ChatOff, off Hotkey, ~*RButton, ChatOff, off Hotkey, ~*MButton, ChatOff, off Hotkey, ~*WheelUp, ChatOff, off Hotkey, ~*WheelDown, ChatOff, off } Else { Hotkey, ~*LButton, ChatOff, on Hotkey, ~*RButton, ChatOff, on Hotkey, ~*MButton, ChatOff, on Hotkey, ~*WheelUp, ChatOff, on Hotkey, ~*WheelDown, ChatOff, on } } ;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Due to the way AHK handles global variables, hotkeys to toggle for the chat ; compatibilty have to be declared BEFORE the hotkeys themselves are set ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; HOTKEYS ;Declare all hotkeys you want disabled when chatting
; CLOSING CHAT BY USING MOUSE BUTTONS ;This script will still work correctly if you use mouse click or scrollwheel to close the chat ;If you don't declare your mouse hotkeys below, the script might break if you use them when chatting
; Guidelines for listing keys in this section: ; separate keys using a comma , ; modifiers such as in ~*Tab or !BS also have to be listed ; spaces are automatically removed ; if you have no keys to declare, leave the variable blank, eg. mapped := ""
; If you declare a hotkey that doesn't exist, the script will crash when you press Enter
;Declare all REMAPPED keys below: ; Remapped keys are keys that are coded like this: ; w::up ; Space::Numpad0 mapped := "w,a,s,d,q,e,t,y,u,f,CapsLock,h"
;Declare all other hotkeys below: hotkeys := "MButton,r,n,k,l,m,+LAlt"
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;ALL hotkeys must be placed below this line ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F9:: ;always on, in case #IfWinActive refuses to work Suspend Off SoundBeep Reload return
;====================================================== #IfWinActive, Company Of Heroes
;Suspend F11:: SoundBeep, 1750, 800 Suspend On return
;Basic/Quick Camera Reset Function Setup Cam: ;Basic camera reset function, remember to use "BlockInput MouseMoveOff" after it { BlockInput MouseMove send {BS} send {BS} MouseClick,WheelDown,,,30,0,D,R } return
;Vehicle click-queue script MButton:: Send {Rbutton} Send {Shift Down} ;Delete this line if you don't want 1st click to be priorized. Loop { if not GetKeyState("MButton", "P") break Send {Rbutton} sleep 20 ;sets delay between clicks } Send {Shift Up} return
Red, Blue & Purple: This is the core of the script. DO NOT TOUCH!
Instructions for hotkey declaration. If you understand them, great! If not, dont worry you can just ignore them. DONT NEED TO TOUCH THIS.
This is the Suspend/Resume function for turning the script on and off when in the lobby. As you can see, F11 is set to suspend, and F9 to suspend off (resume). Unless it is a necessity, you DONT NEED TO TOUCH THIS.
Green & Orange: The orange section of the script is for Remapped Keys, which look like this -
w::up
Remapping Keys is one of the simplest things you do with Autohotkey. Just pick the hotkey you would like to use (e.g. w), followed by a double colon :: , followed by the key you want it to act for/as (up). So your code is w::up. Now when you press w, the camera moves up. Easy! But before we can get this to work, we must declare our hotkey (w) and place it in the long orange section of the script. See below for more info!
The green section of the script is for all other hotkeys, such as the Lay Mine function, which looks like this -
m:: { Send {b} sleep 20 Send {m} } return
Hotkeys like this which perform a function are a little more complicated, but hopefully we can guide you through! Using the above as an example, firstly you pick the hotkey you want to use (e.g. m), followed by a double colon :: . In this function, we want it to select the build menu of our engineer/pioneer/sapper team by sending the b key, followed by selecting mines by sending the m key. So, begining the commands with a curly braket { , we write (send {b}), followed on the next line by (sleep 20). This command causes the script to pause for a fraction of a second, preventing a lag bug occuring. Again, this is followed on the next line by (send {m}). Close the curly braket } , and on the very last line write (return). So the code looks like m:: { Send {b} sleep 20 Send {m} } return Now when a engineer/pioneer/sapper team is selected, you just press the m key, and the build mine option is selected for you! Easy! But before we can get this to work, we must declare our hotkey (m) and place it in the long green section of the script. See below for more info!
DECLARING HOTKEYS Before we can go any further we must declare the hotkeys we intend to use. This is done in the single orange and green lines as seen below...
Firstly, all your hotkeys you want to use must be "declared" in this section here...
QUOTE
;Declare all REMAPPED keys below: ; Remapped keys are keys that are coded like this: ; w::up ; Space::Numpad0 mapped := "w,a,s,d,q,e,t,y,u,f,CapsLock,h"
;Declare all other hotkeys below: hotkeys := "MButton,r,n,k,l,m,+LAlt"
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;ALL hotkeys must be placed below this line ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The orange line is where your remapped hotkeys declarations go. So from our example above our declaration would be
mapped := "w"
The green line is where all your other hotkeys declarations go. So from our Lay Mine function in the example above, our declaration would be
hotkeys := "m"
If you have more than one key to declare, just seperate them with a comma , as seen above. However make sure they are enclosed in the quotation marks " . E.g. hotkeys := "m,n,l,k"
*Note* Hotkeys MUST be declared for the script to work correctly.
PLACING YOUR CODE INTO THE SCRIPT This will only take a moment. So you now have your code and have declared your hotkeys. All that remains is to Cut & Paste your code into the correct section. Remember, place your remapped keys in the orange section, and all others in the green section, as seen below.
;Basic/Quick Camera Reset Function Setup Cam: ;Basic camera reset function, remember to use "BlockInput MouseMoveOff" after it { BlockInput MouseMove send {BS} send {BS} MouseClick,WheelDown,,,30,0,D,R } return
;Vehicle click-queue script MButton:: Send {Rbutton} Send {Shift Down} ;Delete this line if you don't want 1st click to be priorized. Loop { if not GetKeyState("MButton", "P") break Send {Rbutton} sleep 20 ;sets delay between clicks } Send {Shift Up} return
If you wish to organise and name your sections of code, remember to use a semicolon ; at the start of the line. E.g. As seen above...
;Vehicle click-queue script
Again, this is a note just for you, and is completely ignored by the program.
WORKING EXAMPLE Yesyamaha brought up that he just wanted to remove one section of the script, the part with the Auto-reinforce function. This is how it would be done...
Remove ,r from the declaration in this section
QUOTE
; spaces are automatically removed ; if you have no keys to declare, leave the variable blank, eg. mapped := ""
; If you declare a hotkey that doesn't exist, the script will crash when you press Enter
;Declare all REMAPPED keys below: ; Remapped keys are keys that are coded like this: ; w::up ; Space::Numpad0 mapped := "w,a,s,d,q,e,t,y,u,f,CapsLock,h"
;Declare all other hotkeys below: hotkeys := "MButton,r,n,k,l,m,+LAlt"
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;ALL hotkeys must be placed below this line ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F9:: ;always on, in case #IfWinActive refuses to work Suspend Off
And remove ;Auto-reinforce...etc from this section of the script
;Vehicle click-queue script MButton:: Send {Rbutton} Send {Shift Down} ;Delete this line if you don't want 1st click to be priorized. Loop { if not GetKeyState("MButton", "P") break Send {Rbutton}
Full script, with lines to delete highlighted in Red
Spoiler
;Initialisation #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. Process, Priority, , High
;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ; ChatMode ;Author: Xalard ;Don't touch this part unless you know what you are doing. ; Parameters: ; list1 = mapped keys list ; list2 = hotkeys list ; mode: ; on - hotkeys DISABLED ; off - hotkeys ENABLED ; toggle
ChatOff: ;-needed to toggle chat off on mouse click ChatMode(mapped, hotkeys, "off")
ChatMode(list1, list2, mode = "toggle") { static ; space removal StringReplace, list1, list1, %A_Space%,,All StringReplace, list1, list1, &,%A_Space%&%A_Space%,All ;fix for custom key combinations using & StringReplace, list2, list2, %A_Space%,,All StringReplace, list2, list2, &,%A_Space%&%A_Space%,All ; translate the "mode" argument to one to use with "Hotkey" function and set chat status if mode = toggle { mode_hk = toggle chat := !chat } else if mode = on { mode_hk = off chat := 1 } else if mode = off { mode_hk = on chat := 0 } else MsgBox, %mode% is not a valid parameter for ChatMode function! ; execute all necessary "Hotkey" commands if list2 != "" { loop, parse, list2, `, { Hotkey, %A_LoopField%, %mode_hk% } } if list1 != "" { loop, parse, list1, `, { Hotkey, *%A_LoopField%, %mode_hk% Hotkey, *%A_LoopField% up, %mode_hk% } } ; Prevent mouse from fucking up the script If chat = 0 { Hotkey, ~*LButton, ChatOff, off Hotkey, ~*RButton, ChatOff, off Hotkey, ~*MButton, ChatOff, off Hotkey, ~*WheelUp, ChatOff, off Hotkey, ~*WheelDown, ChatOff, off } Else { Hotkey, ~*LButton, ChatOff, on Hotkey, ~*RButton, ChatOff, on Hotkey, ~*MButton, ChatOff, on Hotkey, ~*WheelUp, ChatOff, on Hotkey, ~*WheelDown, ChatOff, on } } ;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Due to the way AHK handles global variables, hotkeys to toggle for the chat ; compatibilty have to be declared BEFORE the hotkeys themselves are set ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; HOTKEYS ;Declare all hotkeys you want disabled when chatting
; CLOSING CHAT BY USING MOUSE BUTTONS ;This script will still work correctly if you use mouse click or scrollwheel to close the chat ;If you don't declare your mouse hotkeys below, the script might break if you use them when chatting
; Guidelines for listing keys in this section: ; separate keys using a comma , ; modifiers such as in ~*Tab or !BS also have to be listed ; spaces are automatically removed ; if you have no keys to declare, leave the variable blank, eg. mapped := ""
; If you declare a hotkey that doesn't exist, the script will crash when you press Enter
;Declare all REMAPPED keys below: ; Remapped keys are keys that are coded like this: ; w::up ; Space::Numpad0 mapped := "w,a,s,d,q,e,t,y,u,f,CapsLock,h"
;Declare all other hotkeys below: hotkeys := "MButton,r,n,k,l,m,+LAlt"
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;ALL hotkeys must be placed below this line ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F9:: ;always on, in case #IfWinActive refuses to work Suspend Off SoundBeep Reload return
;====================================================== #IfWinActive, Company Of Heroes
;Suspend F11:: SoundBeep, 1750, 800 Suspend On return
;Basic/Quick Camera Reset Function Setup Cam: ;Basic camera reset function, remember to use "BlockInput MouseMoveOff" after it { BlockInput MouseMove send {BS} send {BS} MouseClick,WheelDown,,,30,0,D,R } return
;Vehicle click-queue script MButton:: Send {Rbutton} Send {Shift Down} ;Delete this line if you don't want 1st click to be priorized. Loop { if not GetKeyState("MButton", "P") break Send {Rbutton} sleep 20 ;sets delay between clicks } Send {Shift Up} return
;Initialisation #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. Process, Priority, , High
;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ; ChatMode ;Author: Xalard ;Don't touch this part unless you know what you are doing. ; Parameters: ; list1 = mapped keys list ; list2 = hotkeys list ; mode: ; on - hotkeys DISABLED ; off - hotkeys ENABLED ; toggle
ChatOff: ;-needed to toggle chat off on mouse click ChatMode(mapped, hotkeys, "off")
ChatMode(list1, list2, mode = "toggle") { static ; space removal StringReplace, list1, list1, %A_Space%,,All StringReplace, list1, list1, &,%A_Space%&%A_Space%,All ;fix for custom key combinations using & StringReplace, list2, list2, %A_Space%,,All StringReplace, list2, list2, &,%A_Space%&%A_Space%,All ; translate the "mode" argument to one to use with "Hotkey" function and set chat status if mode = toggle { mode_hk = toggle chat := !chat } else if mode = on { mode_hk = off chat := 1 } else if mode = off { mode_hk = on chat := 0 } else MsgBox, %mode% is not a valid parameter for ChatMode function! ; execute all necessary "Hotkey" commands if list2 != "" { loop, parse, list2, `, { Hotkey, %A_LoopField%, %mode_hk% } } if list1 != "" { loop, parse, list1, `, { Hotkey, *%A_LoopField%, %mode_hk% Hotkey, *%A_LoopField% up, %mode_hk% } } ; Prevent mouse from fucking up the script If chat = 0 { Hotkey, ~*LButton, ChatOff, off Hotkey, ~*RButton, ChatOff, off Hotkey, ~*MButton, ChatOff, off Hotkey, ~*WheelUp, ChatOff, off Hotkey, ~*WheelDown, ChatOff, off } Else { Hotkey, ~*LButton, ChatOff, on Hotkey, ~*RButton, ChatOff, on Hotkey, ~*MButton, ChatOff, on Hotkey, ~*WheelUp, ChatOff, on Hotkey, ~*WheelDown, ChatOff, on } } ;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ;ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Due to the way AHK handles global variables, hotkeys to toggle for the chat ; compatibilty have to be declared BEFORE the hotkeys themselves are set ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; HOTKEYS ;Declare all hotkeys you want disabled when chatting
; CLOSING CHAT BY USING MOUSE BUTTONS ;This script will still work correctly if you use mouse click or scrollwheel to close the chat ;If you don't declare your mouse hotkeys below, the script might break if you use them when chatting
; Guidelines for listing keys in this section: ; separate keys using a comma , ; modifiers such as in ~*Tab or !BS also have to be listed ; spaces are automatically removed ; if you have no keys to declare, leave the variable blank, eg. mapped := ""
; If you declare a hotkey that doesn't exist, the script will crash when you press Enter
;Declare all REMAPPED keys below: ; Remapped keys are keys that are coded like this: ; w::up ; Space::Numpad0 mapped := "w,a,s,d,q,e,t,y,u,f,CapsLock,h"
;Declare all other hotkeys below: hotkeys := "MButton,n,k,l,m,+LAlt"
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;ALL hotkeys must be placed below this line ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F9:: ;always on, in case #IfWinActive refuses to work Suspend Off SoundBeep Reload return
;====================================================== #IfWinActive, Company Of Heroes
;Suspend F11:: SoundBeep, 1750, 800 Suspend On return
;Basic/Quick Camera Reset Function Setup Cam: ;Basic camera reset function, remember to use "BlockInput MouseMoveOff" after it { BlockInput MouseMove send {BS} send {BS} MouseClick,WheelDown,,,30,0,D,R } return
;Vehicle click-queue script MButton:: Send {Rbutton} Send {Shift Down} ;Delete this line if you don't want 1st click to be priorized. Loop { if not GetKeyState("MButton", "P") break Send {Rbutton} sleep 20 ;sets delay between clicks } Send {Shift Up} return
Well I think I will remove the auto reinforce part. Its not that I think its cheating or something that gives you an unfair advantage but its just that it has some downsides as well (like draining all ur mp pretty fast especially when US) and I dont want them right now. So do I just delete the
Mmm didnt work for me
*edit* lol sorry beat me to it
Posts: 102
Game: