0

I have problem with reading text from card reader connected to USB. I have method in window:

private void Window_KeyDown(object sender, KeyEventArgs e)
{
    Key k = (Key)e.Key;

    textBoxLogin.Text += k.ToString();
}

Problem is that, it simulates all pressed keys so if in my magnetic card i have something like: !EXAMPLE, that would read LeftShift1LeftShiftELeftShiftX etc.. Any solution how to change it? Btw i know i can click on textBox and then read all from card reader, but that should work with disabled textBox.

Thank u for any answers!

Gerald Versluis
  • 30,492
  • 6
  • 73
  • 100
user1617141
  • 115
  • 1
  • 11
  • Can you take time to reformulate your problem because as it is it's quite difficult to understand ? – franssu Aug 22 '12 at 13:57
  • I have same problem as here: http://stackoverflow.com/questions/10223297/concat-keydown-event-keys-to-one-c-sharp-wpf-string read first post – user1617141 Aug 22 '12 at 14:01
  • 1
    Then can you use the same solution? – Dan Puzey Aug 22 '12 at 14:07
  • Downvoted : question is unclear. – franssu Aug 22 '12 at 14:08
  • Ok so one more time. I have magnetic card reader connected to PC and trying to read string from card. I wrote method which read pressed key and putting it into textBox. Card reader works just like keyboard. SO if in card is information like: $AsD, i wil have in my textBox that values: LeftShift1 LeftShiftA s LeftShiftD (becouse it read shift + pressed button). But i want exactly same information from card in my textbox. I can do it only when i make textBox active, but that should work with disabled textbox. – user1617141 Aug 22 '12 at 14:09
  • 2
    @user1617141 Can you edit your question instead of reformulating it in a comment ? – franssu Aug 22 '12 at 14:23

1 Answers1

1

I guess there is no easy way to convert keys to a string. If you really want to get the text from the Window_KeyDown callback, I think you'll have to code your own converter.

The source of your problem comes from the input : why does the card contains a series of keydown events rather than directly the characters ?

franssu
  • 2,422
  • 1
  • 20
  • 29
  • Card contains only character. There is example directly from card: ;:<>4076451634? But all i can read from it using keyDown is ; LeftShift: etc. – user1617141 Aug 22 '12 at 14:49