Skip to content

Instantly share code, notes, and snippets.

Created June 6, 2014 01:18
Show Gist options
  • Save anonymous/ffa7a21cc17aecac6a67 to your computer and use it in GitHub Desktop.
Save anonymous/ffa7a21cc17aecac6a67 to your computer and use it in GitHub Desktop.
import os
import time
from subprocess import Popen, PIPE
def echochar(char):
if len(char) == 1 and ord(char) >= ord("A") and ord(char) <= ord("Z"):
os.system('xte "keydown Shift_L" "key ' + char + '" "keyup Shift_L"')
else:
os.system('xte "key ' + char + '"')
def echostr(str):
for char in str:
echochar(char)
p = Popen(['zbarcam', '--raw'], stdout=PIPE, stderr=PIPE, stdin=PIPE)
while True:
time.sleep(0.1)
code = p.stdout.readline().strip()
print('Got barcode: {}'.format(code))
echostr(code)
echochar("Tab")
echochar("Tab")
echostr("3")
os.system('xte "keydown Alt_L" "key r" "keyup Alt_L"')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment