Skip to content

Instantly share code, notes, and snippets.

@yarliganfatih
Last active December 17, 2023 19:31
Show Gist options
  • Save yarliganfatih/c970be2204735dfd97ce5fd9da051f2d to your computer and use it in GitHub Desktop.
Save yarliganfatih/c970be2204735dfd97ce5fd9da051f2d to your computer and use it in GitHub Desktop.
printing codes in blocks with commands
import keyboard
import time
def readFile(path):
with open(path, 'r') as file:
arr = file.readlines()
return arr
codeLines = readFile("main.js")
line = 0
def writeConsoleLine():
global line
while codeLines[line]!="\n":
keyboard.write(codeLines[line][:-1])
keyboard.press_and_release("shift+enter")
time.sleep(0.05)
line+=1
keyboard.press_and_release("enter")
line+=1
keyboard.add_hotkey('F9', writeConsoleLine)
keyboard.wait('ctrl+q')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment