【问题标题】:Swap alt keys functionality交换 alt 键功能
【发布时间】:2012-09-27 00:22:47
【问题描述】:

我需要在 Windows 7 中交换 Alt 键功能。一家大公司需要那些在打字机上书写的老人,打字机左侧有变音字符键,但它们是 Win7现在工作有正确的 Alt 用于此目的。

两天的研究让我找到了一个驱动程序解决方案。我需要原始 Windows 7 驱动程序的源代码(两个 .sys 文件似乎是键盘驱动程序),并可能在 Windows DDK 中修改它们。或者我需要制作一个可以与默认驱动程序一起使用的附加驱动程序。如我所见,解决方案将使用 C 或 C++。但是我必须通过什么方式来实现这一点?我应该采取哪些步骤?

限制是:

  1. 仅用于驱动程序安装的一次系统重启。
  2. 在 Win7 中工作时交换 Alt 键的简单方法(同时按下 Alt 键交换)。
  3. 没有需要重新启动的 Win7 键盘重新映射。

稍后添加:我拥有所需的一切,但没有处理交换的代码。例如,我为右 ShiftEnter 做了一个切换,因为只发送了一个扫描码。但是左 Alt 发送一个,右 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);
}

所以我只是简单地交换分别按下和释放两个键的扫描码。右 Alt 正在发送两个扫描码,我不确定它是通过两次调用此函数还是在InputDataStart 结构中生成两个扫描码。我会尝试对每个 Alt 扫描码发出哔哔声,但我们将不胜感激。

【问题讨论】:

  • 您可能想要编写一个类过滤器驱动程序(位于低级设备驱动程序和 kbdclass 之间),而不是尝试修改现有驱动程序。 DDK 包含一个示例键盘过滤器驱动程序以及 kbdclass 的源代码,可以作为参考。
  • 我会尝试并提供反馈。
  • 我已经为 .sys 构建了 kbfilter(示例键盘过滤器驱动程序),安装了它(在设备管理器中按照说明)并重新启动了 Windows - 键盘停止工作,它只是没有响应按键.我需要卸载此驱动程序才能使键盘再次工作(通过屏幕键盘)。似乎,DDK(确切地说是 WDK 7.1.0)中的原始 kbfilter 声称可以正常工作而无需更改 - 无法正常工作。我已经完成了 kbfiltr.htm 文件中的整个过程。我没有使用 Visual Studio 或除了 build.exe 之外的任何其他东西,并且需要一个文件来安装驱动程序。有什么帮助吗?
  • 无需驱动程序签名即可启动 Win7。
  • 您是否考虑过使用像 SharpKeys 这样的键盘重新映射器(注册表修复)? sharpkeys.codeplex.com

标签: windows swap alt-key


【解决方案1】:

解决方案:

if (InputDataStart->MakeCode==0x38 || InputDataStart->MakeCode==0xb8)
    InputDataStart->Flags^=KEY_E0;

交换左右 Alt 键功能。

现在我需要使交换可配置。为了最好 - 按两个 Alt。

【讨论】:

  • 上述解决方案是针对 Alt 键按下 (make) 和释放 (break)。我已经制作了过滤器驱动程序,其中 Print Screen 键在 Windows 7 x64 中正常工作时交换 Alts。我认为这可以通过同时按下它们来交换 Alts。这只是多一点代码。现在不需要这样做。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-15
  • 2012-04-14
  • 2018-08-29
  • 2010-10-04
  • 1970-01-01
相关资源
最近更新 更多