Skip to content

Instantly share code, notes, and snippets.

@flandolf
Created September 20, 2022 02:31
Show Gist options
  • Save flandolf/7a18cdadf743eefc84d52370790b3dd8 to your computer and use it in GitHub Desktop.
Save flandolf/7a18cdadf743eefc84d52370790b3dd8 to your computer and use it in GitHub Desktop.
monkeytype cheat (300+ wpm - adjustable)
# requires pytesseract for OCR
# requires keyboard
import os
from time import sleep
from PIL import Image
import pytesseract
import keyboard
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
flist = []
os.scandir('.')
for file in os.scandir('.'):
if file.name.endswith('.png') or file.name.endswith('.jpg'):
flist.append(file.name)
else:
continue
print("Files: ")
if len(flist) == 0:
print("No files found!")
exit()
elif len(flist) == 1:
print("Only one file found, using it.")
file = flist[0]
else:
for i in range(len(flist)):
print("{}. ".format(i) + flist[i])
file = input("Select file: ")
file = flist[int(file)]
text = pytesseract.image_to_string(Image.open(file), lang='eng')
print("Set delay (default=5seconds): ")
delay = input()
if delay == '':
delay = 5
for i in range(0,delay):
print("Starting in {} seconds...".format(delay-i))
sleep(1)
for i in range(0, len(text)):
keyboard.write(text[i])
sleep(0.0245)
print("Writing: " + text[i])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment