4

标准韩语键盘上的空格键旁边有两个键(每侧一个),我想将它们重新映射为 Control 或 Alt 修饰符 - 所以我可以使用比我的小指更强的手指交替使用(我是 emacs 用户) .

我猜问题是它们似乎没有生成KeyUp事件,并且它们不会像其他键一样重复。我有一个非常糟糕的解决方案,涉及使用自动热键的循环。还对另一个非免费程序 KeyManager 做了类似的事情。我希望有一些更高级的技巧或解决方法(AutoHotkey、驱动程序或其他)。

;Scan Code for Hanja Key
sc1F1::
Loop 10000
{
SetKeyDelay,-1
Send {Blind}{LCtrl DownTemp}
}
SetKeyDelay,-1
Send {Blind}{LCtrl Up}
Return

按下(并按住)的键盘挂钩输出Hanja

您可以看到没有重复和向上事件。

VK  SC  Type    Up/Dn   Elapsed Key     Window
74  03F     u   0.08    F5              
19  1F1     d   0.66    Hanja           
74  03F     d   9.58    F5       

更新:

试过:

sc1F1 & t::Send {Blind}{LCtrl DownTemp}{t}{LCtrl Up}

结果:

Hanja+后t,热键会触发,但随后仅按ONLY 执行相同的操作。 似乎没有发生。t LCtrl Up

安倍的SetTimer重置还是不错的!感觉就像我的原始代码的一个更优雅的版本。然而,问题在于延迟——我必须调整输入速度以匹配延迟。

其他经过测试的解决方案:

GetKeyState("vk19", "p")总是在脚本加载和第一次按下后报告 PRESSED。它永远不会打破这种状态——即使在我释放密钥很久之后。

KeyWait也不能按预期工作。

sc1F1 up::traytip,, test在任意数量的按下/释放后也不会产生托盘提示。

4

3 回答 3

1

Have the script send{Ctrl down}
and then set a timer to run a subroutine after a desired amount of time (600ms in the example)
(the - makes it only run once)
to send {Ctrl up}:

sc1F1::
Sendinput, {Ctrl Down}
SetTimer, Reset, -600
Return

Reset:
Sendinput, {Ctrl Up}
Return

→SetTimer←</a>


If you wanted to make it a toggle button,
i.e press it once and x sends Control + A,
then press it again to return x to normal behavior:

sc1F1::Flag:=!Flag

#If Flag
x::Sendinput, ^a
a::Sendinput, test
#If

The value of variable Flag is reversed with every press of sc1F1,
i.e. Flag is either set to 1 or 0.
#If Flag is shorthand for #If Flag = 1
This example requires
Autohotkey_L (newer/recommended version) because it uses the #If command.

Using AHK basic it would look like:

sc1F1::Flag:=!Flag

$x::
if Flag
    Send, ^a
Else
    Send, x
Return

Other options/examples using
Capslock in place of sc1F1
:

You could try using & if you just want to use the button as a modifier.
This example turns Capslock into a modifier (the first line keeps the capslock light off):

SetCapsLockState, AlwaysOff

capslock & x::traytip,, %a_thishotkey%

If you want Capslock to send something when pressed alone
you will need to add something like:

capslock::Send, something

and then that will only then 'something' on the release of Capslock.

→Additional information←</a>


Here is an example where X and A perform differently if Capslock is physically ("p") held down:

SetCapsLockState, AlwaysOff
#If GetKeystate("capslock","p")
x::traytip,, %a_thishotkey%
a::traytip,, %a_thishotkey%
#If

You could also try setting a variable ("Flag"),
and then clearing it with a timer.

capslock::
Flag := 1
SetTimer, Reset, 600
Return

Reset:
Flag := 0
Return

#If Flag
x::Sendinput, ^a
a::Sendinput, test
#If

Manual reference:
#If
GetKeyState()


Another option is installing a keyboard hook.
Then you can check what the last pressed key was with the built-in variable: a_priorkey

#InstallKeybdhook

x::
if (a_priorkey = "Capslock") {
    Traytip,, %a_thishotkey%
} Return

→More on built-in variables←</a>


If all else fails you could try:
Remapping via the Registry's "Scancode Map"

于 2012-08-14T01:07:23.803 回答
1

组装,

我还没有完成这个想法,但这会是另一种方法吗?它会显示您按下了哪些键,直到(在这种情况下按下回车键),但您可以创建自己的“完成”条件,然后“组合”按键以创建您的 Alt 或 Ctrl 组合。

sc038:: ; Start when (in this case) the left Alt is pressed, {LAlt} is NOT listed in the input list....
input:=""
   Loop
   {
        Input, in, L1, {Enter}{LControl}{RControl}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
        EL=%ErrorLevel%
        ToolTip, %EL% and %in% and %A_ThisHotkey%
        if EL = EndKey:Enter
        {
            ToolTip
            Sleep, 5000
            Break
        }
   }
Return
于 2012-08-13T07:18:12.280 回答
0

也许我没有正确理解这个问题,但我找到了这些键的关键特殊代码,这对我有用:

SC11D:: RCtrl
SC138:: RAlt

不确定谁会使用 Alt 重映射,但为了完整起见......

在 Win8 上使用韩语 Microsoft IME 工作。

于 2014-08-02T03:30:07.373 回答