USB Magnetic Stripe Reader |
We can use it to read the information contained in the magnetic cards.
Below I post the C# code in order to capture the swipe:
- Add the event:
public Form1() { InitializeComponent(); KeyPreview = true; KeyPress += Form1_KeyPress; }
- Manage the event KeyPress in the form:
private bool inputToLabel = true; void Form1_KeyPress(object sender, KeyPressEventArgs e) { if (inputToLabel) { label1.Text = label1.Text + e.KeyChar; e.Handled = true; } else { e.Handled = false; } if (e.KeyChar == (char)Keys.Enter) // if is the last char I do something { // I do something } }
Please let me know if you have problems.
Nessun commento:
Posta un commento