Skip to content

Instantly share code, notes, and snippets.

@Giszmo
Forked from anonymous/gist:ffa7a21cc17aecac6a67
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Giszmo/03d1036d287f300992ec to your computer and use it in GitHub Desktop.
Save Giszmo/03d1036d287f300992ec to your computer and use it in GitHub Desktop.
# this little script helps me enter bitcoin addresses in bitcoin-core.
# It enters an address that I scan, skips to the value field, enters 3
# and adds another recipient. I made it to charge paper wallets with 3mɃ.
import os
import time
from subprocess import Popen, PIPE
upper_pattern='xte "keydown Shift_L" "key {}" "keyup Shift_L"'
default_pattern='xte "key {}"'
ord_A=ord("A")
ord_Z=ord("Z")
def echochar(char):
pattern=default_pattern
if len(char) == 1 and ord(char) >= ord_A and ord(char) <= ord_Z:
pattern=upper_pattern
os.system(pattern.format(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