Conditional hotkey or include in AutoHotKey
Posted
by Bowen
on Super User
See other posts from Super User
or by Bowen
Published on 2009-12-18T15:35:54Z
Indexed on
2010/03/14
5:05 UTC
Read the original article
Hit count: 695
Is there a way to define a Hotkey conditionally in AutoHotKey? I want to do different keyboard mappings for different machines with different physical keyboards.
This is what I want to do:
RegRead, ComputerName, HKEY_LOCAL_MACHINE, System\CurrentControlSet\Control\ComputerName, ComputerName
If ( ComputerName = BDWELLE-DIM8300 )
{
#Include %A_ScriptDir%\Mappings-BDWELLE-DIM8300.ahk
}
OR
RegRead, ComputerName, HKEY_LOCAL_MACHINE, System\CurrentControlSet\Control\ComputerName, ComputerName
If ( ComputerName = BDWELLE-DIM8300 )
{
LWin::LAlt
[more hotkey definitions that only apply to this machine]
}
but since AHK parses Hotkey definitions and #Include statements BEFORE interpreting If statements, the Hotkeys definitions (whether buried in an #Include or not) do not respect the If condition.
Thanks for pointing me to AutoHotKey_L!
Do you have a specific example of how to conditionally define a hotkey? The syntax is very confusing. Here's what I'm trying (after having installed AutoHotKey_L.exe in place of AutoHotKey.exe):
RegRead, ComputerName, HKEY_LOCAL_MACHINE, System\CurrentControlSet\Control\ComputerName, ComputerName
#If ( ComputerName = BDWELLE-DIM8300 )
LWin::LAlt
but that doesn't seem to work...
© Super User or respective owner