I am trying to write program that will recognize when a device such as a magnetic swipper is used. I was thinking that I could somehow bind the device to something in my program but I am not sure what I would use to bind it. I thought that the device might have a keycode or something like that that I could use, but i don't know how i would find it.

Could someone please explain to me how this type of thing works or how i could do something of this nature?

Thanks in advance for ANY help or suggestions.

How is the swipper connected to the computer. If it is through a serial port, then you can use pyserial and detect when there is data in the serial port to be read. Without more info there is no way to help.

I looked into these things a while ago and was a bit surprised to read that the swiper threads its input data into the keyboard, via a driver it comes with.

In that case you can use standard keyboard reads such as raw_input().

Alternatively some swipers come with cables to hook into a serial port, which seems a lot safer to me. In which case you should be set with pyserial.

The device I have uses keyboard interface, but I might want to run my program in the background so there wouldn't be a console window. I might use a GUI if I can't run my program in the background. The device is fed in through a USB port. How would I detect when the device is used and not get that confused with when a key on the keyboard is pressed.

The swipper may send an identifying string at the beginning of the transmission. Take a look a the first few bytes. You will probably have to use ord() since the best way to distinguish it as something other than the keyboard is to use decimal values that the keyboard would not transmit.

Thank you so much.. that solves my problem.