proof of concept: Send what you mean
Posted: 26 Nov 2017, 19:40
- The idea behind this script is for something like SendInput, ^v to work the same way, regardless of the keyboard layout. Or more specifically, it will work based on the array specified in the function, by converting parts of the string to something else.
- You may also be able to choose a different array to refer to based on what the current keyboard layout is. Do an Internet search for: AutoHotkey GetKeyboardLayout.
- You may also be able to choose a different array to refer to based on what the current keyboard layout is. Do an Internet search for: AutoHotkey GetKeyboardLayout.
Code: Select all
q::
vKeys := "^v"
;vKeys := "^c"
SendEx(vKeys)
return
SendEx(vKeys)
{
;static oArray := Object("v","{vk56}", "w","{U+63}")
;static oArray := Object("v","{vk56}")
;static oArray := Object("v","{U+76}")
static oArray := {}, vIsInit
if !vIsInit
{
Loop, 26
oArray[Chr(96+A_Index)] := "{vk" Format("{:X}", 0x40+A_Index) "}"
vIsInit := 1
}
Loop, 3
vUnused%A_Index% := Chr(A_Index)
vKeys := StrReplace(vKeys, "{{}", "{" vUnused1 "}")
vKeys := StrReplace(vKeys, "{}}", "{" vUnused2 "}")
vKeys := StrReplace(vKeys, "{", "{" vUnused3)
vKeys := StrReplace(vKeys, "}", "}" vUnused3)
vOutput := ""
Loop, Parse, vKeys, % vUnused3
{
vTemp := A_LoopField
if (SubStr(vTemp, 1, 1) = "{")
{
vOutput .= vTemp
continue
}
Loop, Parse, vTemp
{
vChar := A_LoopField
if oArray.HasKey(vChar)
vOutput .= oArray[vChar]
else
vOutput .= vChar
}
}
vOutput := StrReplace(vOutput, "{" vUnused1 "}", "{{}")
vOutput := StrReplace(vOutput, "{" vUnused2 "}", "{}}")
vOutput := StrReplace(vOutput, vUnused3)
;MsgBox, % vOutput
SendInput, % vOutput
}