Last active
August 29, 2015 14:22
-
-
Save joetde/2150b6a6846ac2719f5b to your computer and use it in GitHub Desktop.
Cheat script for 10fastfingers.com
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
#!/bin/python2 | |
# rudimentary script to cheat on 10fastfingers.com (yeah this is useless) | |
# requires gnome-screenshot, imagemagick (convert), xte and tesseract (+ data-eng) | |
import subprocess | |
def h_exec(cmd): | |
""" Exec command and return stdout as string""" | |
proc = subprocess.Popen(cmd,stdout=subprocess.PIPE) | |
return ("".join(filter(lambda x:x and x!='\n', proc.stdout.readlines()))).replace("\n", " ") | |
def press(keys): | |
""" Write on keyboard the given string """ | |
for c in keys: | |
if c.isalpha(): | |
h_exec(["xte", "key "+c]) | |
else: | |
if c==" ": | |
h_exec(["xte", "key space"]) | |
def h_alt_tab(): | |
""" Do alt tab """ | |
h_exec(["xte", "keydown Alt_L", "key Tab", "keyup Alt_L"]) | |
def h_screenshot(): | |
""" Take screenshot and crop for game """ | |
h_exec(["gnome-screenshot", "-f", "/tmp/1.png", "-w"]) | |
h_exec(["convert", "/tmp/1.png", "-crop", "820x92+235+252", "/tmp/2.png"]) | |
def read_screen(): | |
h_screenshot() | |
return h_exec(["tesseract", "/tmp/2.png", "stdout", "-l", "eng", "-psm", "3"]) | |
h_alt_tab() | |
for i in range(20): | |
press(read_screen()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment