Created
June 6, 2014 01:18
-
-
Save anonymous/ffa7a21cc17aecac6a67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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