Skip to content

Instantly share code, notes, and snippets.

@mlongval
Last active December 13, 2015 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlongval/4950010 to your computer and use it in GitHub Desktop.
Save mlongval/4950010 to your computer and use it in GitHub Desktop.
AutoKey code snippet to insert the current date. The original version did not work, I think because I am using Python3
"""
This is for use in the AutoKey text expander under Linux
The version of this script that came with the program does not work
on my system...
I think it's because I use python3
Returns the current date. in the dd/mm/yyyy format
version 1.0
13/02/2013
mlongval _at_ gmail _dot_ com
NB: hacked together in a few minutes... not really tested
use at your own risk
tags: autokey, date, linux, python3
"""
# imports
import subprocess
# definitions
def decodeAndStrip(value):
value = value.decode("utf-8")
value = value.strip()
return(value)
#end def decodeAndStrip
# main()
theDate = subprocess.check_output('date +"%d/%m/%Y"', shell=True)
keyboard.send_keys(decodeAndStrip(theDate))
#end program
@mlongval
Copy link
Author

Updated, for error in last line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment