Skip to content

Instantly share code, notes, and snippets.

@mzfr
Created March 16, 2020 13:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mzfr/49831c90a3175671809025718173b769 to your computer and use it in GitHub Desktop.
Save mzfr/49831c90a3175671809025718173b769 to your computer and use it in GitHub Desktop.
auto type all of your content
#!/usr/bin/env python3
'''This script help to automate the process of writing the
large content to places where copy paste might not work.
Ex: learning management systems which take code as an input
might not allow copy and paste, there we can use this kind of
trickery.
The only disadvantage of this is that it might fail to provide
proper indentation. So that will have to be done manually.
'''
import subprocess
import time
# Time to switch tabs, so you can get the cursor
# to the position where typing has to be done
time.sleep(3)
# Path to the file that contains the data to be typed
filepath = "code.c"
# xdotool is a tool that is used to perform the typing process.
# You can install it using your package manager on linux systems.
subprocess.call(["xdotool type --file %s --delay 5" % filepath], shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment