15

I have a system where I have multiple keyboards and really need to know which keyboard the key stroke is coming from. To explain the set up:

  1. I have a normal PC and USB keyboard
  2. I have an external VGA screen with some hard-keys
  3. The hard keys are mapped as a standard USB keyboard, sending a limited number of key-codes (F1, F2, Return, + and -)

I have a low-level hook (in C# but actually calling upon Win32 functionality) which is able to deal with the input even when my application is not focused.

The problem is that when using the normal keyboard, some of the mapped key-codes at picked up by the application being driven on the external screen. One of the key-presses sent by the external screen and used for confirmation is VK_RETURN. Unless I can identify the "device" and filter upon it, the user could be performing actions and confirming them on a screen their not even looking at.

How do I know which keyboard was responsible for the key-press?

4

2 に答える 2

16

はい、私は正直に立っています、私の悪い、毎日何か新しいことを学んでいます。

これがそれを補うための私の試みです:):

  • 生の入力に使用するデバイス(2つのキーボード)を:: RegisterRawInputDevices()で登録します。

  • これらのデバイスは、GetRawInputDeviceList()から取得できます。

  • デバイスを登録すると、WM_INPUTメッセージの受信が開始されます。

  • WM_INPUTメッセージのlParamには、入力元のキーボードを判別するために使用できるRAWKEYBOARD構造に加えて、仮想キーコードとメッセージのタイプ(WM_KEYDOWN、WM_KEYUP、...)が含まれています。

  • したがって、最後のメッセージの送信元のフラグを設定して、それを通常のキーボード入力ハンドラーにディスパッチできます。

于 2008-09-18T14:18:25.167 に答える
-3

これを行う方法はありません。Windows はこれを抽象化します。前述のように、デバイス ドライバーを作成/変更する必要があります。

于 2008-09-18T10:01:56.330 に答える