交换alt键功能

时间:2012-09-27 00:22:48

标签: windows key swap alt

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

两天的研究让我得到了驱动解决方案。我需要原始Windows 7驱动程序的源代码(两个.sys文件似乎是键盘驱动程序),并且可能在Windows DDK中修改它们。或者我需要制作一个可以使用默认驱动程序的附加驱动程序。我可以看到,解决方案是C或C ++。但是我还有什么办法来实现这个目标呢?我应该采取什么措施?

限制是:

  1. 仅为驱动程序安装重启一个系统。
  2. 在Win7中工作时交换 Alt 键的简单方法(通过同时按下它们来交换 Alt 键)。
  3. 无需重新启动Win7键盘,需要重新启动。
  4. 稍后添加:我有我需要的一切,但没有处理交换的代码。例如,我已经为右 Shift Enter 进行了切换,因为只发送了一个扫描码。但是左 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 扫描码发出哔哔声,但您的帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

解决方案:

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

交换左右Alt键功能。

现在我需要进行交换配置。最好的 - 按下Alts​​。

相关问题