0

I am developing application on Windows Mobile 6 (uses compact framework). The application uses a barcode scanner. I want to implement keyboard shortcuts in the menu. I have implemented a keypress event in the menu so that if the user presses 1 the first menu item is opened and so on. But my problem is that if the user scans the barcode with the device while the application is in the menu, the application gets the barcode read by the scanner and translates it to keypresses. As I have keyboard shortcuts implemented in submenus as well, this means that if the user scans the barcode in the menu the application moves between menus.

I am not 100% sure but it seems that devices I use have barcode readers as "keyboard wedge" and when they are that kind you get text from them as if the user was typing it from the keyboard.

This is how keypresses in the menu are implemented:

private void mainList_KeyPress(object sender, KeyPressEventArgs e)
    {
            switch (e.KeyChar)
            {
                case (char)Keys.D1:
                    productRequestBtn_Click(sender, e);
                    break;
                case (char)Keys.D2:
                    warehouseBtn_Click(sender, e);
                    break;
                case (char)Keys.D3:
                    inventoryBtn_Click(sender, e);
                    break;
                case (char)Keys.D4:
                    ordersBtn_Click(sender, e);
                    break;
                case (char)Keys.D5:
                    discountBtn_Click(sender, e);
                    break;
                case (char)Keys.D6:
                    intakeBtn_Click(sender, e);
                    break;
                case (char)Keys.F1:
                    Close();
                    break;
            }
    }

I have tried different ways to implement it but haven't managed to solve my problem.

If someone has any idea how to either change keyboard shortcuts implemented in menus, block a barcode reader or anything that might work in the described case, I would really appreciate it.

3
  • Turn off wedge-mode and use the vendor-supplied barcode SDK to directly control (and receive scan events from) the integrated scanner. Commented Feb 28, 2014 at 16:45
  • I can't use vendor SDK as application needs to work with different vendor device. Commented Mar 3, 2014 at 13:58
  • Up to you, but I've found it is worth the effort to abstract out the vendor SDK and add support for the ones you need. There are not that many data collection device vendors out there. That being said, if you insist on using wedge mode, then utilize the preamble and postamble as suggested by @josef. Commented Mar 3, 2014 at 14:05

1 Answer 1

1

Yep, using the barcode scanner sdk would be the best solution.

If want to avoid to code that OEM specific stuff you may workaround your issue using the keyboard wedges pos- and/or pre-amble settings.

Most if not all of the wedge implementations support adding a sequence before and after the scanned data, this may be called preamble and postanble. Using this feature you can change your code and for example disregard and keypresses if they start with * and end with # for example. If so, just add * as preamble and # as postamble in the wedge setup of your device. Using this technique you have to remove the chars in your barcode input field before you go on and validate/process the barcode data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.