It is in fact possible to rebind alt (or I assume shift/ctrl) in wow using autohotkey. However, if you want to use alt as a modifier on any other hotkeys using ahk, then youâll need to use a keyboard hook.
For example, these rebinds work on their own:
LAlt::`
*c::
Send, {sc38 Down} ;alt down
KeyWait, c
Send, {sc38 UP} ;alt up
Return
But if you were to try to add the following hotkey, then LAlt::` would stop working properly.
<!s::x ;lalt + s
If you would like to use <! (lalt) as a modifier, you must use a keyboard hook as shown below:
; script based on https://www.autohotkey.com/boards/viewtopic.php?f=76&t=66655&p=291059
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
if not A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%" ; Requires v1.0.92.01+
ExitApp
}
#SingleInstance, Force
SetBatchLines, -1
; based on https://autohotkey.com/boards/viewtopic.php?f=6&t=26059
hHookKeybd := DllCall("SetWindowsHookEx", "int", 13 ; WH_KEYBOARD_LL = 13
, "ptr", RegisterCallback("Keyboard")
; hMod is not required on Win 7, but seems to be required on XP even
; though this type of hook is never injected into other processes:
, "ptr", DllCall("GetModuleHandle", "ptr", 0, "ptr")
, "uint", 0, "ptr") ; dwThreadId
GroupAdd, Wow, ahk_exe wow.exe
GroupAdd, Wow, ahk_exe Wow.exe
return
Keyboard(nCode, wParam, lParam) {
Critical
if (wParam=0x104 && NumGet(lparam+4, "UInt") = 0x1F) ; WM_SYSKEYDOWN (alt) + s
SetTimer, SendXdn, -0
if (wParam=0x105 && NumGet(lparam+4, "UInt") = 0x1F) { ; WM_SYSKEYUP (alt) + s
SetTimer, SendXup, -0
}
if (wParam=0x100 && NumGet(lparam+4, "UInt") = 0x1F) { ; s down
SetTimer, SendSdn, -0
}
if (wParam=0x101 && NumGet(lparam+4, "UInt") = 0x1F) { ; s up
SetTimer, SendSdn, off
SetTimer, SendSup, off
}
return DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", wParam, "ptr", lParam, "ptr")
}
SendXdn:
If WinActive("ahk_group Wow")
Send, {x down}
Return
SendXup:
If WinActive("ahk_group Wow")
Send, {x up}
Return
SendSdn:
If WinActive("ahk_group Wow") && !GetKeyState("LAlt", "P")
Send, {s down}
Return
SendSup:
If WinActive("ahk_group Wow") && !GetKeyState("LAlt", "P")
Send, {s up}
Return
#If WinActive("ahk_group Wow")
LAlt::`
!s::Return ;to prevent lalt from being sent by the sendxdn function
*s Up::Send, {s up} ;to fix the sendsup function from not actually sending s up properly
*c::
Send, {sc38 Down}
KeyWait, c
Send, {sc38 UP}
Return
#If
^Esc::ExitApp
This is based on these two threads:
https://autohotkey.com/boards/viewtopic.php?f=6&t=26059
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=66655&p=291059