How to make Autokey type Unicode characters?
I have a problem with Autokey: I can't copy-paste through it a special Unicode character. Here is an example:
I am French, and in French writing, you use a space before a semi-colon. But in formal typography, you don't use a regular space before a semi-colon but a ‘narrow no-break space’ which is the Unicode character U+202F.
So when I am writing formal things in French, instead of always wasting time typing CTRL+Shift+U+202F
+ENTER+;+space', I would like to use an Autokey new phrase. Using the abbreviation Space+;;
(which means, verbally, typing space, then semi-colon twice). Which means when I type (anywhere) space+;;
, autokey transforms it into ;
(which is a narrow no-break space followed by a semi-colon).
BUT the problem here is this: when I create a new phrase in Autokey with ;
, then when I use the abbreviation, Autokey replaces it only with ;
, erasing the narrow no-break space. And it appears it does this with any other too-special Unicode character...
Does anyone have an idea of how to get round this issue?
Thanks a million!
Two options: (See my blog for more details and screenshots for option 1)
First option (much simpler)
Upgrade to the python 3 port of autokey (because python 3 deals with unicode characters better than python 2)
For me, the installation worked as follows:
# Edit (April 2018). Autokey now uses python 3 by default. So try
pip3 install autokey
# Install the original autokey
sudo apt-get install autokey-gtk
# Update autokey to python 3 using pip3
pip3 install --user autokey-py3
Then make sure you run the python3 version, which is probably at
~/.local/bin/autokey-gtk
With this method, you can enter your unicode characters as phrases
Second option (if you can't get autokey-py3 to work)
Use a python script (File -> New -> Script) together with the system's clipboard
Paste the following into the script
import sys
reload(sys)
sys.setdefaultencoding('utf8')
from subprocess import Popen, PIPE
def paste_character(symbol):
c = Popen(['xclip', '-selection', 'clipboard'], stdin=PIPE)
c.communicate(symbol.encode('utf-8'))
keyboard.send_keys('<ctrl>+v')
paste_character('γ')
This works by changing the default python settings to work with unicode correctly. It then sends the chosen character to the clipboard (ensure you have xclip
installed). Here I've used γ as an example). Then it sends control+v to paste the character.
Extras for second option
The second method can be improved by taking all but the last line of the script and putting it in a file (lets call it MyCopy.py
). Then, in Autokey's preferences (Script Engine), tell Autokey where this file is. Then the script becomes
from MyCopy import paste_character
paste_character('γ')
Some applications don't use control+v for paste (eg terminal uses control+shift+v). But the character will still be on the clipboard.