Application Focus - KeyboardHook key_pressed chars are lower cased

Aug 16, 2012 at 12:16 PM

Hi everybody.

First I want to say thanks to the author for this great project.

I’m having a problem working with the Keyboard-Hook.

I want to use the keyboard hook to detect keyboard-barcode scanner usings in the application.

But here’s the problem:

For example, I have the following barcode-sequence that will be scanned:

“$F$1$$”

In my application I’m registering the Keyboard-Hook: new KeyboardHookListener(new GlobalHooker());and registering the KeyboardHookListener-KeyPress Event where I catch the scanned KeyChars.

But the problem is:

When my application does not have the focus, the scanned barcode is pretty right: “$F$1$$”

But, when my application does have the focus, the scanned barcode sequence is: “4f4144”

I don’t know whats the problem. Does anyone know what the Problem could be?

At last I want to excuse my probably bad English, I’m from Germany ;-).

Coordinator
Aug 17, 2012 at 3:59 AM

Seems to me like Shift or CapsLock detection problem. Could you please post the code of your event handler. I wonder if you have same issue with the demo application.

Wegen deinem Englisch muss dir wirklich keine Sorge machen. Lies mal  die anderen Kommentare. :D
Grüße
George

Aug 17, 2012 at 1:45 PM

public void MyKeyPress(object sender, KeyPressEventArgs e)
        {  
            Debug.WriteLine("Key pressed :" + e.KeyChar);   

            CheckIfSpecialSequence(e);

        }

In the method, i work with the e.KeyChar.

But here's the log when the application has the focus:

Key pressed: p

Key pressed: 4

Key pressed: f

Key pressed: 4

Key pressed: 1

Key pressed: 4

Key pressed: 4

 

And here's the log when the application has not the focus (this is the right sequence, and right barcode that is scanned):

Key pressed: $

Key pressed: F

Key pressed: $

Key pressed: 1

Key pressed: 1

Key pressed: $

Key pressed: $

This appears in my application, but also in the test application from this source.
I am running my OS as a WIN7 64 Bit Professional, and the hook as x86.

Aug 21, 2012 at 7:15 AM
Edited Aug 21, 2012 at 7:47 AM

It seems that the "Hook" eliminates some key presses like "^" for example. Maybe there's a connection between these two issues...

Maybe there's a shift problem in AppendModifierStates-Funktion in KeyEventArgsExt.cs and in InvokeKeyPress in the KeyboardHookListener.cs. It seems, that when i scan the barcode, the first keypress that should be $, so SHIFT + 4 (german keyboard), the shift is eliminated and the result is only 4 then.

 

 

When i hold shift and scan the barcode, the result is:

Key pressed: $
Key pressed: F
Key pressed: $
Key pressed: !  --Here's the only wrong, should be 1....
Key pressed: $
Key pressed: $

Nov 7, 2012 at 12:27 PM

/push

 

Any ideas?