Autohotkey 在自动热截取中使用键盘和外部numpad

Autohotkey 在自动热截取中使用键盘和外部numpad,autohotkey,Autohotkey,我需要的是将我的键从外部numpad映射到键盘上的键。我已经决定使用evilC的自动热截取程序。总体目标是能够在我的键盘上使用windows鼠标键。我已经到了这样的地步,程序同时注册了我的numpad和键盘的输入,我可以用键盘输入数字,但这并不会真正影响windows鼠标键 这就是我到目前为止所做的: #SingleInstance force #Persistent #include Lib\AutoHotInterception.ahk AHI := new AutoHotIntercep

我需要的是将我的键从外部numpad映射到键盘上的键。我已经决定使用evilC的自动热截取程序。总体目标是能够在我的键盘上使用windows鼠标键。我已经到了这样的地步,程序同时注册了我的numpad和键盘的输入,我可以用键盘输入数字,但这并不会真正影响windows鼠标键

这就是我到目前为止所做的:

#SingleInstance force
#Persistent
#include Lib\AutoHotInterception.ahk

AHI := new AutoHotInterception()

keyboardId := AHI.GetKeyboardId(0x04D9, 0x8008)
numPadId := AHI.GetKeyboardId(0x0C45, 0x7663)

AHI.SubscribeKeyboard(numPadId, true, Func("KeyEvent"))
AHI.SubscribeKeyboard(keyboardId, true, Func("KeyEvent"))

return

KeyEvent(code, state){
ToolTip % "Keyboard Key - Code: " code ", State: " state    
if (state) & (code=30)
{
    Send, {NumpadUp}
}
}

^Esc::
    ExitApp

主要问题是您需要在硬件驱动程序级别发送输入以触发WMK

那么我想说你的问题看起来很奇怪。这似乎自相矛盾?
你想从外部键盘重新映射按键,但你也说你只想在主键盘上使用numpad?那么,外置键盘的实际用途是什么呢

无论如何,这里有一些建议和修改后的脚本,您可以根据自己的使用进行调整。所以首先,真的没有必要订阅整个键盘。只需订阅你想要的密钥

因为我不清楚你到底想做什么,所以我将展示一个例子,演示如何在硬件驱动程序级别将A、S和d重新映射到Numpad1、Numpad2和Numpad3

#include Lib\AutoHotInterception.ahk

AHI := new AutoHotInterception()

;kind of optional 
;if you don't switch up stuff, you'll always have the same id
keyboardId := AHI.GetKeyboardId(..., ...)

;binding arguments to the function object to make use of the same function over and over
;so don't need to define a new function for each key
AHI.SubscribeKey(keyboardId, GetKeySC("a"), true, Func("KeyEvent").Bind(GetKeySC("numpad1")))
AHI.SubscribeKey(keyboardId, GetKeySC("s"), true, Func("KeyEvent").Bind(GetKeySC("numpad2")))
AHI.SubscribeKey(keyboardId, GetKeySC("d"), true, Func("KeyEvent").Bind(GetKeySC("numpad3")))
return

;the key argument will be the argument we bound to the function object above
;the AHI library takes care of passing in the state argument
KeyEvent(key, state)
{
    global keyboardId
    AHI.SendKeyEvent(keyboardId, key, state)
}

^Esc::ExitApp
这里记录了发送输入


(旁白,你有没有可能为OSR做这件事?

你好,泰,答案就这么多了。不幸的是,剧本没有起作用。你试过自己测试吗?我想问题可能是我有65%的键盘实际上没有numpad,这就是我买外置键盘的原因。这就是为什么代码的这一部分:.Bind(GetKeySC(“numpad1”))不能在我的键盘上找到我的numpad键,对吗?我不认为是这样,但我也不能真正测试它,所以我不能说。当然
GetKeySC()
至少应该返回一个正确的扫描码。你注意到我没有填写键盘id吗?这只是一个例子。此外,还可以修改代码,以便从外部numpad发送。只需更改键盘ID。