Created
March 2, 2020 02:42
-
-
Save ShawnMilo/88262d404f798407d19d1869b1ccadba 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
#!/usr/bin/env python | |
import os | |
import sys | |
from time import sleep | |
from random import randrange | |
import re | |
fkey = re.compile(r'^F\d$') | |
from subprocess import check_output | |
default_delay = "" | |
dev_mode = os.getenv("DEVMODE") == "true" | |
if len(sys.argv) > 2: | |
default_delay = sys.argv[-1] | |
int(default_delay) | |
with open(sys.argv[1], 'r') as raw: | |
lines = raw.readlines() | |
def delay(): | |
if dev_mode: | |
return "10" | |
if default_delay != "": | |
return default_delay | |
return str(randrange(100, 200)) | |
for line in lines: | |
if line.startswith("KEY "): | |
line = line[4:].strip() | |
check_output(['xdotool', 'key', line]) | |
continue | |
elif line.startswith("NOTE "): | |
line = line[5:] | |
print line | |
if dev_mode: | |
sleep(0.1) | |
else: | |
raw_input() | |
continue | |
for char in line: | |
check_output(['xdotool', 'type', '--delay', delay(), char]) | |
sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment