simulating keyboard input from usb rfid reader

Discussion in 'Mac Programming' started by sgthree, Jan 6, 2013.

  1. sgthree macrumors newbie

    Feb 10, 2012
    I have a usb device which reads rfid tags. On my window pc I have a program which takes the code from a scanned chip and sends it as a 12 character string to whatever program has the keyboard focus. I need to accomplish the same result on a mac running OS X 10.8

    I can read the input from the device from /dev/cu.SLAB_USBtoUART, and have written a command line objective-C program that massages the input to remove the extraneous info and sends the required 12 character code to stdout.

    How to I get the system to treat the output from this program as keyboard input?

    The end result that I want is for the scanned code to be entered into a form field in a web browser running on the mac with a return so that when an rfid chip is scanned, the web brewer submits a form with that chips code.
  2. ytk macrumors regular

    Jul 8, 2010
    I think you're saying you just want to send the text you get from the reader as if it were typed text? If so, you can do this with AppleScript.

    tell application "System Events" to keystroke "foobar"
    You can easily issue AppleScript commands from the command line (or another application) using osascript:

    osascript -e 'tell application "System Events" to keystroke "foobar"'
  3. balamw Moderator


    Staff Member

    Aug 16, 2005
    New England

Share This Page