AutoKey - clipboard.get_selection() function fails on certain strings

Posted by LonnieBest on Stack Overflow See other posts from Stack Overflow or by LonnieBest
Published on 2012-06-25T06:21:40Z Indexed on 2012/06/30 9:16 UTC
Read the original article Hit count: 314

I've simplified my script so you can focus on the essence my problem.

In AutoKey (not AutoHotKey), I made a Hot-Key (shift-alt-T) that performs this script on any string I have highlighted (like in gedit for example -- but any other gui editor too).

strSelectedText = clipboard.get_selection()
keyboard.send_keys(" " + strSelectedText)

The script modifies the highlighted text and adds a space to the beginning of the string.

It works for most strings I highlight, but not this one:

* Copyright © 2008–2012 Lonnie Best. Licensed under the MIT License.

It works for this string:

* Add a Space 2.0.1

but not on this one:

* Add a Space 2.0.1 –

At the python command prompt, it has no problem any of those strings, yet the clipboard.get_selection() function seems to get corrupted by them.

I'm rather new to python scripting, so I'm not sure if this is an AutoKey bug, or if I'm missing some knowledge I should know about encoding/preparing strings in python.

Please help. I'm doing this on Ubuntu 12.04:

sudo apt-get install autokey-qt

© Stack Overflow or respective owner

Related posts about python

Related posts about encoding