[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 565
  • Last Modified:

card swipe/bar code pen capture?

How can I capture the input from a card swipe/bar code pen which connects with a keyboard passthru so that I can send it to an application which does not neccessarily have the focus. I need to be able to keep the thing monitored at all times and not interfere with keyboard input meant for other active applications. Any help on this will be greatly appreciated.
0
Foyal
Asked:
Foyal
  • 5
  • 3
  • 2
  • +1
1 Solution
 
zsiCommented:
The manufactureer of the scanning device will have provided a driver.  When information is scanned in, whatever visual control on the screen has the focus will receive the input (if it is capable of receiving input).

The device simply emulates the keyboard.  Depending on the brand of scanner that you have, you should be able to program to the interface so that your application can receive notification and have to opportuinity to bypass the information.

However, intercepting an arbitrary device is probably not possible. For security reasons, I am sure you can understand why a manufacturer might not let you do this.  Also, I don't know of any windows message that might get broadcast during the scanning process.  
0
 
FoyalAuthor Commented:
Since this will not work for the application as required I had to reject ZSI's answer... In order to perform the function described in my question, will it be neccessary for me to use a different type of scanner (serial port) and then poll the port constantly in order to make sure my app can recieve any input from the scanner while allowing keyboard input meant for other active apps? If this is true, can someone direct me to a source example for such a thing?
0
 
zsiCommented:
Why not use an OCX control that communicates with a scanner?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
FoyalAuthor Commented:
zsi-
That still leaves the problem of being able to intercept scanner input and use it in this particular app while allowing other active applications to have the user's focus for keyboard or mouse input.
Foyal
0
 
StapleheadCommented:
Foyal,

You have a scanner with a keyboard wedge?  (Out of curiosity, what brand is it?)
If so, all it does is allow your scanner to "pretend" it's the keyboard. Typically, it's possible to configure the wedge to send a header or trailer character, so you can identify (programmatically) the difference between scanned & keyed input.

However, unless you write code to monitor the keyboard buffer and intercept scanned data before it gets to the active control, the scanned data will go to the active app.

Why is this your design?  Is this a POS app?  if so, does it make sense for your scanning to be totally modeless?  (i.e., i can understand allowing a scan at any point while your app is running.  in that case, just (!) code all relevant controls to look for the header char, grab the data until the trailer char, and send the data to the relevant routine.) would your user, for instance, scan while in netscape, let's say?
0
 
FoyalAuthor Commented:
Staplehead-
The reason for having this app continuously receive any input from the scanner is that is will be remotely located in order to track personnel entry (similar to a time clock). If the machine on which the program is running should be used by someone at its location for any other purpose (like internet access, email, calculator, etc), then my app should still be able to work in the background (minimized). I would very much like to keep the scanning part from being proprietary as far as the scanner hardware is concerned, although this may not prove to be possible. Intercepting all user input and filtering it for scanner input may be the best answer. Do you know if all scanner hardware has the functionality to add the special characters you mentioned? If not, could you specify some brand which does? The original hardware I mentioned (with the keyboard passthrough) does not have a manufacturer name on it anywhere, just a large sticker which says W-WEDGE and a S/N: Y50115012953. If this sounds familiar, let me know who you think the manufacturer may be so I can contact them.
Thanks,
Foyal
0
 
StapleheadCommented:
Foyal,

When I was doing barcode work, I used Compsee wedges.  Can't say much about other brands, since it was a company decision made before I was there.  here's a URL for ya:
       http://www.tennecom.com/barcode/compsee/genwed.htm

i noticed that they talk about the kinds of output chars you can embed.  instead of making your app look for all keyboard input, maybe you could activate it on a certain key combination; as long as the wedge can send it out (and why shouldn't it be able to?!), you'd be set.  (caveat: i haven't done this sort of thing in VB, and offhand, don't have any implementation detail advice; if you don't have Appelman's API book or the hardcore VB book, i could take a look in them for ya).

i'd think, though, that this is a better approach thaan attempting to trap _all_ keyboard input.

keep something in mind, though: throw a keyboard wedge into the mix, and that's yet another piece of hardware to control.  they _do_ go down, or "lose" their programming occasionally (frequency depends on the environment, how "gentle" your users are, etc.).  it will _not_ be a support-free installation, but hopefully, not support-intensive...

0
 
FoyalAuthor Commented:
Staplehead-
Thanks for the info. I will check out the url you posted.
See ya
Foyal
0
 
kfrickCommented:
Foyal:

I think you were very close to the answer yourself, when you suggested using the serial port.

You can write a simple VB application to react to any activity on a selected serial port, and place the data where it needs to be in your application (it is usually pretty easy to add a serial control (MSCOMM32.OCX) to your existing project).

Load the Custom Control, and set it's properties to the available comm port, proper baud rate, etc. If the Scanner/Reader device has a constant length data string, set the RThershold property to that length, else set RThreshold to 1. This will fire the Control's "On Comm" event upon the reception of the proper number of characters. This way, you don't have to actively poll the comm port, it will wake up your app when there is data in the buffer.

If you set the RThreshold to 1, you have to make sure you get the entire message. It helps to have each transmission from the Reader/Scanner start and stop with a control character (STX, EOT) to properly identify the data.

The on-line help for the MSComm control has a decent example. The more error-checking you can throw at it, the better, because serial communications have a tendancy to get corrupted in the real world.

I never actually tried to parse raw keyboard input data and divert it, but it just sounds too complicated if a dedicated serial port is an option. We regularly write applications connecting several RS232 devices to a PC. The Microsost Communications Tool has served us very well.

0
 
StapleheadCommented:
kfrick:

your answer is right: setting the app to use a serial port *is* easier on the coder... you hardcode which serial port you want, and away you go!

only problem is, you better hope that your user never wants to use that com port, or doesn't attach the wedge to the wrong port ("well, this plug is 9-pin, and that port is 9-pin" !!!).

i agree, though: in a perfect world, the more control the developer has on the user's hardware, the easier; if you can't ensure that level of control, wedging into the keyboard is more "standard", fwiw !

Foyal:

in any case, an ounce of prevention is worth _hours_ of, well, troubleshooting.  don't allow your wedge to autodiscriminate if you're only using one symbology; better yet, since barcodes exist on (relatively) perishable media, go magstrip if at all possible or within budget.  remind your client that perishables costs tend to outstrip initial implementation costs in the long run: CYA with the _most_ _solid_ design you can get them to sign off with up front.  also, since you're dealing with peripherals, decide what's the maximum failure rate you're willing to guarantee, and do some sort of data collection & reporting; that way, when (not if) the system fails during run-time down the line, you can run your metrics and say, "sorry! can you say 'T&M'???"  ;^)

            Larry
0
 
FoyalAuthor Commented:
kfrick and staplehead-
Thanks to both of you for your help on this question. I think I am going to with the serial port solution. Should be receiving the new hardware to begin testing in a day or two.
Thanks Again...
Foyal
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now