Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Distinguish between Keyboard and basic Barcode Scanner

Distinguish between Keyboard and basic Barcode Scanner

Scheduled Pinned Locked Moved C#
question
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    J Cod3r
    wrote on last edited by
    #1

    Hi, Does someone know if it is possible to know if characters that was received, was received from the Keyboard or from the Barcode scanner? Thanks X|

    S B D D 4 Replies Last reply
    0
    • J J Cod3r

      Hi, Does someone know if it is possible to know if characters that was received, was received from the Keyboard or from the Barcode scanner? Thanks X|

      S Offline
      S Offline
      Simon P Stevens
      wrote on last edited by
      #2

      If your scanner is like ours, then no. I would suggest you try asking the manufacturers of the scanner.

      1 Reply Last reply
      0
      • J J Cod3r

        Hi, Does someone know if it is possible to know if characters that was received, was received from the Keyboard or from the Barcode scanner? Thanks X|

        B Offline
        B Offline
        Brad Wick
        wrote on last edited by
        #3

        I am in need of the same thing. We use symbol scanners and I know that I read somewhere that most manufactures have a dll file to integrate with your applications. This hasnt been something I have looked into yet but will be very shortly. Can you let me know if you find out something, or maybe we can help each other complete this?

        J 1 Reply Last reply
        0
        • J J Cod3r

          Hi, Does someone know if it is possible to know if characters that was received, was received from the Keyboard or from the Barcode scanner? Thanks X|

          D Offline
          D Offline
          Dirso
          wrote on last edited by
          #4

          You could try to measure the time delay between one char and another.. Barcode readers can be configurated to send the chars one after the another very quickly, humans can't

          1 Reply Last reply
          0
          • J J Cod3r

            Hi, Does someone know if it is possible to know if characters that was received, was received from the Keyboard or from the Barcode scanner? Thanks X|

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            If it's a keyboard wedge scanner, then no, there's no way to tell. Though, most scanners will let you setup a preamble/postamble sequence that the scanner pre-/post-pends to the data it "types", like adding "@@" to the string. So, if you scan a barcode of "123456789", the scanner actually sends "@@123456789". How I've done it in the past is to set my form's KeyPreview to True, and in the KeyDown event of the form, I look for the "@" character (in this example). If I keep getting the preamble sequence, then I know the next numbers I get are for the barcode and I redirect that data appropriately.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007, 2008

            B 1 Reply Last reply
            0
            • B Brad Wick

              I am in need of the same thing. We use symbol scanners and I know that I read somewhere that most manufactures have a dll file to integrate with your applications. This hasnt been something I have looked into yet but will be very shortly. Can you let me know if you find out something, or maybe we can help each other complete this?

              J Offline
              J Offline
              J Cod3r
              wrote on last edited by
              #6

              Brad, Did you see the comment from Dave Kreskowiak, i think this will work. Your scnner should come with a form containing different bar codes. These are used to configure the scanner. Cheers

              B 1 Reply Last reply
              0
              • J J Cod3r

                Brad, Did you see the comment from Dave Kreskowiak, i think this will work. Your scnner should come with a form containing different bar codes. These are used to configure the scanner. Cheers

                B Offline
                B Offline
                Brad Wick
                wrote on last edited by
                #7

                Yes I saw that, and I think that is what I am going to do. I wish I did not have to do this as I like the barcode application to send just the barcode so it can work with other things I have but appears to be the only choice. I use the POS-X Xi3000 ( http://www.posguys.com/barcode-scanner\_3/POS-X-Xi3000\_716/XI3000U\_9177/\[[^](http://www.posguys.com/barcode-scanner_3/POS-X-Xi3000_716/XI3000U_9177/ "New Window")] ) which is a great scanner, but I wish they had the ability to capture the scanner just like Symbol does.

                1 Reply Last reply
                0
                • D Dave Kreskowiak

                  If it's a keyboard wedge scanner, then no, there's no way to tell. Though, most scanners will let you setup a preamble/postamble sequence that the scanner pre-/post-pends to the data it "types", like adding "@@" to the string. So, if you scan a barcode of "123456789", the scanner actually sends "@@123456789". How I've done it in the past is to set my form's KeyPreview to True, and in the KeyDown event of the form, I look for the "@" character (in this example). If I keep getting the preamble sequence, then I know the next numbers I get are for the barcode and I redirect that data appropriately.

                  A guide to posting questions on CodeProject[^]
                  Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                       2006, 2007, 2008

                  B Offline
                  B Offline
                  Brad Wick
                  wrote on last edited by
                  #8

                  I am trying to figure out the best way to integrate this so that it can be customizable. My barcodes are always 12 characters long but you never know what might change in the future. So my thought is to look for two @@ which means were starting the barcode and then two @@ means the barcode has ended. I have activated the forms keypreview so I can now watch the keys on KeyPress. The problem I am having is trying to figure out the best way to make this dynamic and customizable by a config file incase the user wants to use three #'s instead of @.

                  // First we set the config variables as to what the barcode variables will be
                  private static string ConfigBarcodePreSuffix = "@";
                  private static int ConfigBarcodePreSuffixTimes = 2;
                  
                  // Set the form variables so we can capture whats going on
                  private static string Scanned_BarcodeText = ""; // Will hold the final barcode value
                  private static bool Scanned_BarcodeBeingScanned = false; // Will hold a bool value so we know we scanning the barcode
                  private static int Scanned_PreSuffixFoundTimes = 0; // How many times have we found this presuffix
                  
                  private void frmEventTicketVerify_KeyPress(object sender, KeyPressEventArgs e)
                  {
                      if (e.KeyChar.Equals(ConfigBarcodePreSuffix))
                      {
                          // This is the character were looking for so lets find out if its the start or end
                          if (!Scanned_BarcodeBeingScanned)
                          {
                              // We have not started scanning the barcode so lets see if we hit it
                              if (Scanned_PreSuffixFoundTimes == ConfigBarcodePreSuffixTimes)
                              {
                                  // This is how many times they are looking for the prefix so lets start the barcode
                                  Scanned_BarcodeBeingScanned = true;
                              }
                          }
                          else
                          {
                              // This is the ending of the barcode
                              if (Scanned_PreSuffixFoundTimes == ConfigBarcodePreSuffixTimes)
                              {
                                  // This is how many times they are looking for the prefix so lets start the barcode
                                  Scanned_BarcodeBeingScanned = false;
                              }
                          }
                          // Move the prefix count up
                          Scanned_PreSuffixFoundTimes++;
                      }
                      else
                      {
                          // This wasnt the key we were looking for so lets reset it
                          Scanned_PreSuffixFoundTimes = 0;
                      }
                  
                      if (Scanned_BarcodeBeingScanned)
                      {
                          // We are still inserting text from the barcode, so lets continue to add it
                          Scanned_BarcodeText += e.KeyChar.ToString();
                      }
                      else if (!Scanned_BarcodeText.Trim().E
                  
                  D 1 Reply Last reply
                  0
                  • B Brad Wick

                    I am trying to figure out the best way to integrate this so that it can be customizable. My barcodes are always 12 characters long but you never know what might change in the future. So my thought is to look for two @@ which means were starting the barcode and then two @@ means the barcode has ended. I have activated the forms keypreview so I can now watch the keys on KeyPress. The problem I am having is trying to figure out the best way to make this dynamic and customizable by a config file incase the user wants to use three #'s instead of @.

                    // First we set the config variables as to what the barcode variables will be
                    private static string ConfigBarcodePreSuffix = "@";
                    private static int ConfigBarcodePreSuffixTimes = 2;
                    
                    // Set the form variables so we can capture whats going on
                    private static string Scanned_BarcodeText = ""; // Will hold the final barcode value
                    private static bool Scanned_BarcodeBeingScanned = false; // Will hold a bool value so we know we scanning the barcode
                    private static int Scanned_PreSuffixFoundTimes = 0; // How many times have we found this presuffix
                    
                    private void frmEventTicketVerify_KeyPress(object sender, KeyPressEventArgs e)
                    {
                        if (e.KeyChar.Equals(ConfigBarcodePreSuffix))
                        {
                            // This is the character were looking for so lets find out if its the start or end
                            if (!Scanned_BarcodeBeingScanned)
                            {
                                // We have not started scanning the barcode so lets see if we hit it
                                if (Scanned_PreSuffixFoundTimes == ConfigBarcodePreSuffixTimes)
                                {
                                    // This is how many times they are looking for the prefix so lets start the barcode
                                    Scanned_BarcodeBeingScanned = true;
                                }
                            }
                            else
                            {
                                // This is the ending of the barcode
                                if (Scanned_PreSuffixFoundTimes == ConfigBarcodePreSuffixTimes)
                                {
                                    // This is how many times they are looking for the prefix so lets start the barcode
                                    Scanned_BarcodeBeingScanned = false;
                                }
                            }
                            // Move the prefix count up
                            Scanned_PreSuffixFoundTimes++;
                        }
                        else
                        {
                            // This wasnt the key we were looking for so lets reset it
                            Scanned_PreSuffixFoundTimes = 0;
                        }
                    
                        if (Scanned_BarcodeBeingScanned)
                        {
                            // We are still inserting text from the barcode, so lets continue to add it
                            Scanned_BarcodeText += e.KeyChar.ToString();
                        }
                        else if (!Scanned_BarcodeText.Trim().E
                    
                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #9

                    Well, I didn't do much beyond glancing at the code, but I can tell you you're going about this wrong. The prefix can be any combination of characters (usually - depends on the barcode scanner) and doesn't have to be the same character repeating. On top of that, it's not a good idea to use the same combination of chracters for the pre and postambles. You won't be able to tell the difference between the start and stop combinations.

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                         2006, 2007, 2008

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups