我需要在Windows 7中交换Alt键的功能。一家大公司需要为在打字机上写字的老年人提供这种功能,打字机的左侧有变音字符键,但他们正在开发的Win7现在有右键Alt+kbd>。
经过两天的研究,我找到了一个驱动程序解决方案。我需要原始Windows7驱动程序的源代码(两个.sys
文件似乎是键盘驱动程序),并可能在WindowsDDK中修改它们。或者我需要制作一个额外的驱动程序来使用默认的驱动程序。正如我所看到的,解决方案应该是在C或C++中。但是我必须走什么路才能做到这一点呢?我应该采取哪些步骤?
限制是:
- 仅为安装驱动程序而重新启动一个系统
- 一种在Win7中工作时交换Alt键的简单方法(通过同时按下Alt键来交换它们)
- 没有需要重新启动的Win7键盘重新映射
稍后添加:我有我需要的一切,但没有处理交换的代码。例如,我切换到了右Shift和Enterlt发送一个,右Alt发送两个扫描码:
VOID
KbFilter_ServiceCallback(
IN PDEVICE_OBJECT DeviceObject,
IN PKEYBOARD_INPUT_DATA InputDataStart,
IN PKEYBOARD_INPUT_DATA InputDataEnd,
IN OUT PULONG InputDataConsumed
)
/*++
Routine Description:
Called when there are keyboard packets to report to the Win32 subsystem.
You can do anything you like to the packets. For instance:
o Drop a packet altogether
o Mutate the contents of a packet
o Insert packets into the stream
Arguments:
DeviceObject - Context passed during the connect IOCTL
InputDataStart - First packet to be reported
InputDataEnd - One past the last packet to be reported. Total number of
packets is equal to InputDataEnd - InputDataStart
InputDataConsumed - Set to the total number of packets consumed by the RIT
(via the function pointer we replaced in the connect
IOCTL)
Return Value:
Status is returned.
--*/
{
PDEVICE_EXTENSION devExt;
WDFDEVICE hDevice;
hDevice = WdfWdmDeviceGetWdfDeviceHandle(DeviceObject);
devExt = FilterGetData(hDevice);
if (InputDataStart->MakeCode==0x1c)
InputDataStart->MakeCode=0x36;
else if (InputDataStart->MakeCode==0x36)
InputDataStart->MakeCode=0x1c;
else if (InputDataStart->MakeCode==0x9c)
InputDataStart->MakeCode=0xb6;
else if (InputDataStart->MakeCode==0xb6)
InputDataStart->MakeCode=0x9c;
(*(PSERVICE_CALLBACK_ROUTINE)(ULONG_PTR) devExt->UpperConnectData.ClassService)(
devExt->UpperConnectData.ClassDeviceObject,
InputDataStart,
InputDataEnd,
InputDataConsumed);
}
因此,我只需交换分别按下和松开两个键的扫描码。RightAlt正在发送两个扫描代码,我不确定它是通过两次调用该函数来发送,还是在InputDataStart
结构中生成两个扫描码。我会尝试在每次Alt扫描代码时发出嘟嘟声,但如果您能提供帮助,我将不胜感激。
解决方案:
if (InputDataStart->MakeCode==0x38 || InputDataStart->MakeCode==0xb8)
InputDataStart->Flags^=KEY_E0;
其交换左右Alt键功能。
现在我需要配置交换。为了达到最佳效果-按下两个Alts。