Speed Up Autokey Phrase Insertion

144 views
Skip to first unread message

Simon K.

unread,
Dec 17, 2021, 12:12:27 PM12/17/21
to autokey-users
Hi, 
is there any way to speed up the process of Autokey inserting long Phrases? I have to insert approx. 300 words and it always takes 5-10s. 
Greetings
Vladi

Sam Sebastian

unread,
Dec 18, 2021, 8:06:30 AM12/18/21
to autoke...@googlegroups.com
Try using clipboard insertion instead of keyboard

--
You received this message because you are subscribed to the Google Groups "autokey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autokey-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autokey-users/97549e5d-9d38-486a-89ef-8143e3aa6e9fn%40googlegroups.com.

Kreezxil

unread,
Dec 19, 2021, 10:20:10 AM12/19/21
to autokey-users
Build your phrase in a variable, shove it into the clipboard, paste the clipboard. I do this on some things where I want the insertion to be super fast.

if you're using the macro expansion only mechanism you want to set pasteg using clipboard using keyboard.png

if you're using python scripting then do

wall_of_text="300 words here, however you generated it, doesn't matter for the example"
clipboard.fill_clipboard(wall_of_text)
keyboard.send_keys("<ctrl>+v")

Simon K.

unread,
Dec 20, 2021, 2:02:52 PM12/20/21
to autokey-users
Ok, cool, I'll try it out. Thanks!

Simon K.

unread,
Dec 20, 2021, 2:26:10 PM12/20/21
to autokey-users
Ok, I triied changing to "Paste using Clipboard Ctrl+V", but now, when I use enter my phrase nothing happens besides my input goes idle, so that I can not use my keyboard anymore and have to restart my computer. 
Plus: Is there any way to change the "Paste using" Method of all the phrases in a folder at once? 
Thanks and Greetings
Simon

Kreezxil

unread,
Dec 20, 2021, 6:02:02 PM12/20/21
to autokey-users
You shouldn't have to restart your computer, please share your phrase or script, and a screenshot of what you set.

jos...@main.nc.us

unread,
Dec 20, 2021, 7:37:40 PM12/20/21
to autoke...@googlegroups.com
It shouldn't hang like that. We'd need a trace to see what's happening.
If you have the time, check out
https://github.com/autokey/autokey-python2/wiki/Problem-Reporting-Guide.

As for mass updating, it's doable, but tedious to do manually and easy if
you know any scripting language such as bash.

By default, all your script and phrase folders are under
$HOME/.config/autokey/data. If your script is named myscript, then there
are two files. The script itself is in myscript.py and the metadata (what
you want to change in this instance) is in .myscript.json. If your phrase
is named myphrase, the two files are myphrase.txt and .myphrase.json.

All the metadata file names start with a . which makes them hidden files
in Linux, but there are various ways to display them such as using ls -a.
(That funny business is going away in 0.96.)

Near the end of each phrase JSON file is a parameter which controls pasting.
It will usually be

"sendMode": "kb"

or

"sendMode": "<ctrl>+v"

First, copy the files you want to change to an empty working directory.
That way, if you make a mistake or my code is wrong, nothing important
gets damaged. Only copy the files back when you're done and happy with the
results.

So to mass edit a bunch of these, write a bash script (or similar) that
calls sed with something like this UNTESTED code:

#!/bin/bash
## arguments are the files to modify
## This modifies the source files, so make backups!!
## This example changes all the files from Paste using keyboard
## to Paste using clipboard (Ctrl+V)

for filename in "$@"
do
sed -i -e '/sendMode/s/kb/\<ctrl\>\+v/' "$filename"
done

Copy this into a file called something like pastemod in the same working
directory and make it executable.
chmod 755 pastemod

then run it as
./pastemod list of files or ".*.json"

Experiment with just one file until it works.

The double quotes are necessary if any of your phrase names contain blanks
or other special characters that don't belong in Linux file names, but are
legal.

This loops through all the files listed when you call it.
It runs sed, the stream editor.

Sed modifies the files directly (-i) using the command following the -e.

The command ignores all lines that don't contain 'sendMode'. This makes
everything much easier and safer.
When it finds a line with sendMode in it, it replaces kb with <ctrl>+v.
All the backslashes are there to make sure sed treats the next character
as plain text and not as something that tells it what to do.

You can use the same approach for any similar changes you may want to make.

If sed is too obtuse for your taste, awk is a lot easier to program and
debug and is much more manageable when there are any decisions to handle.

If you expect to use the command line at all, learning the basics of these
two tools will greatly expand your capabilities and are way more than
worth the required effort.

Joe

> Ok, I triied changing to "Paste using Clipboard Ctrl+V", but now, when I
> use enter my phrase nothing happens besides my input goes idle, so that I
> can not use my keyboard anymore and have to restart my computer.
> Plus: Is there any way to change the "Paste using" Method of all the
> phrases in a folder at once?
> Thanks and Greetings
> Simon
>
> On Monday, December 20, 2021 at 8:02:52 PM UTC+1 Simon K. wrote:
>
>> Ok, cool, I'll try it out. Thanks!
>>
>> On Sunday, December 19, 2021 at 4:20:10 PM UTC+1 kree...@gmail.com
>> wrote:
>>
>>> Build your phrase in a variable, shove it into the clipboard, paste the
>>> clipboard. I do this on some things where I want the insertion to be
>>> super
>>> fast.
>>>
>>> if you're using the macro expansion only mechanism you want to set
>>> *pasteg
>>> using clipboard* [image: using keyboard.png]
>>>
>>> if you're using python scripting then do
>>>
>>> *wall_of_text="300 words here, however you generated it, doesn't matter
>>> for the example"*
>>> *clipboard.fill_clipboard(wall_of_text)*
>>> *keyboard.send_keys("<ctrl>+v")*
>>> On Saturday, December 18, 2021 at 7:06:30 AM UTC-6 sebasti...@gmail.com
>>> wrote:
>>>
>>>> Try using clipboard insertion instead of keyboard
>>>>
>>>> On Fri, Dec 17, 2021, 12:12 Simon K. <ausge...@gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>> is there any way to speed up the process of Autokey inserting long
>>>>> Phrases? I have to insert approx. 300 words and it always takes
>>>>> 5-10s.
>>>>> Greetings
>>>>> Vladi
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "autokey-users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>> send
>>>>> an email to autokey-user...@googlegroups.com.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/autokey-users/97549e5d-9d38-486a-89ef-8143e3aa6e9fn%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/autokey-users/97549e5d-9d38-486a-89ef-8143e3aa6e9fn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to autokey-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/5eba92ef-1827-4127-8f53-d5c6a38d7659n%40googlegroups.com.
>


Kreezxil

unread,
Dec 21, 2021, 8:13:47 AM12/21/21
to autoke...@googlegroups.com
sed supports wildcarding for files btw joe, so the for loop isn't even necessary. :) I learned that last month.

You received this message because you are subscribed to a topic in the Google Groups "autokey-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/autokey-users/XmsZaUdzghQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to autokey-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autokey-users/9247a3e398054e70ef7d06c77e9a6e66.squirrel%40www.main.nc.us.

Simon K.

unread,
Dec 22, 2021, 7:44:03 AM12/22/21
to autokey-users
Hey Guys, 

thanks for the support and big thanks to Joe for the much detailed information. I already use a script that a friend of mine made for me to create phrases (txt+json) out of a .csv file. I think I should be able to add the clipboard setting to the generated json files. 

Regarding the error, I get following output in the Terminal: 

File "/usr/lib/python2.7/dist-packages/autokey/interface.py", line 500, in __sendStringClipboard
File "/usr/lib/python2.7/dist-packages/autokey/interface.py", line 537, in __fillClipboard
    self.clipBoard.set_text(string.encode("utf-8"))
TypeError: Gtk.Clipboard.set_text() takes exactly 3 arguments (2 given)

I tried updating the scripting.py and interface.py files like stated in this thread: https://code.google.com/archive/p/autokey/issues/212
But afterwards Autokey did not start anymore. 

I think maybe I am just using an old version of Autokey (namely 0.90.4), but I am also not able to uninstall it (I installed it using apt I think, but if I try apt remove, it says that Autokey is not installed). 

Thanks for your help again!

Kreezxil

unread,
Dec 22, 2021, 11:54:31 AM12/22/21
to autokey-users
Simon K. please attach your script and a sample data file so we can have something to work with while we figure it out.

Simon K.

unread,
Dec 22, 2021, 11:59:14 AM12/22/21
to autokey-users
Hi, 

the script has nothing to do with the "Paste using Clipboard" feature not working. I tried creating a phrase manually and it still gives me the same error I described above. 
I still attach my Pyhtonscript, just in case somebody can use it to create multiple phraes from a .csv table. 

Greetings
Vladi

columns-to-text.py

jos...@main.nc.us

unread,
Dec 23, 2021, 2:48:08 AM12/23/21
to autoke...@googlegroups.com
That error message highlights the main problem you are facing. 0.90.4 is
ancient (around 8 years old). A lot has happened since then and we need to
get that off your system before addressing any remaining problems.

Before addressing the specifics, the first thing you need to do is to make
a backup of your AutoKey configuration so all your scripts and phrases are
safe. The easiest way to do that would be to copy the entire folder.

cp -a $HOME/.config/autokey $HOME/.config/autokey_saved

Now, let's find out where AutoKey lives. Tell us what the following
command says. Replace qt with gtk in the command if you are using the GTK
version of AutoKey.

find / -name autokey-qt 2>/dev/null

Once we know where it is, we can proceed to get rid of it before
installing the current version.

Joe
>> You received this message because you are subscribed to a topic in the
>>> Google Groups "autokey-users" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/autokey-users/XmsZaUdzghQ/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> autokey-user...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/autokey-users/9247a3e398054e70ef7d06c77e9a6e66.squirrel%40www.main.nc.us
>>> .
>>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to autokey-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/f9bb25b6-7eec-40d5-b12a-fc589d024ae5n%40googlegroups.com.
>


Johnny Rosenberg

unread,
Dec 24, 2021, 3:38:53 PM12/24/21
to autoke...@googlegroups.com
Den tors 23 dec. 2021 kl 08:48 skrev <jos...@main.nc.us>:
That error message highlights the main problem you are facing. 0.90.4 is
ancient (around 8 years old). A lot has happened since then and we need to
get that off your system before addressing any remaining problems.

Before addressing the specifics, the first thing you need to do is to make
a backup of your AutoKey configuration so all your scripts and phrases are
safe. The easiest way to do that would be to copy the entire folder.

cp -a $HOME/.config/autokey $HOME/.config/autokey_saved

Now, let's find out where AutoKey lives.  Tell us what the following
command says. Replace qt with gtk in the command if you are using the GTK
version of AutoKey.

find / -name autokey-qt 2>/dev/null

If you only want to know where the executable file lives, then why not just using there whereis command?
On my system whereis seems to be (in this particular case) about 340 times faster…

~ $ time find / -name autokey-gtk 2>/dev/null
/usr/share/doc/autokey-gtk
/usr/bin/autokey-gtk

real 0m2,750s
user 0m1,452s
sys 0m1,271s
~ $ time whereis autokey-gtk
autokey-gtk: /usr/bin/autokey-gtk /usr/share/man/man1/autokey-gtk.1.gz

real 0m0,008s
user 0m0,001s
sys 0m0,007s
~ $


Kind regards

Johnny Rosenberg

jos...@main.nc.us

unread,
Dec 24, 2021, 10:23:01 PM12/24/21
to autoke...@googlegroups.com
Not sure it really makes a difference in this case, but find and whereis
work completely differently which explains the timing. One thing that
might make find better for this is that it looks everywhere and tells you
everything it finds whereas whereis will stop on the first executable
match it finds in your PATH. If you have a local copy and a system copy,
it will only find one of them. I'd like to clean out whatever is there for
a fresh start, so find might be better.

This discusses it in more detail.

https://superuser.com/questions/707906/why-whereis-and-which-dont-show-me-location-of-command

Joe

> Den tors 23 dec. 2021 kl 08:48 skrev <jos...@main.nc.us>:
>
>> That error message highlights the main problem you are facing. 0.90.4 is
>> ancient (around 8 years old). A lot has happened since then and we need
>> to
>> get that off your system before addressing any remaining problems.
>>
>> Before addressing the specifics, the first thing you need to do is to
>> make
>> a backup of your AutoKey configuration so all your scripts and phrases
>> are
>> safe. The easiest way to do that would be to copy the entire folder.
>>
>> cp -a $HOME/.config/autokey $HOME/.config/autokey_saved
>>
>> Now, let's find out where AutoKey lives. Tell us what the following
>> command says. Replace qt with gtk in the command if you are using the
>> GTK
>> version of AutoKey.
>>
>> find / -name autokey-qt 2>/dev/null
>>
>
> If you only want to know where the executable file lives, then why not
> just
> using there whereis command?
> On my system whereis seems to be (in this particular case) about 340 times
> faster…
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *~ $ time find / -name autokey-gtk
> 2>/dev/null/usr/share/doc/autokey-gtk/usr/bin/autokey-gtkreal 0m2,750suser
> 0m1,452ssys 0m1,271s~ $ time whereis autokey-gtkautokey-gtk:
> /usr/bin/autokey-gtk /usr/share/man/man1/autokey-gtk.1.gzreal 0m0,008suser
> 0m0,001ssys 0m0,007s~ $*
>> https://groups.google.com/d/msgid/autokey-users/85d17ebfe1c1a34c9b72de3d2fc31996.squirrel%40main.nc.us
>> .
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to autokey-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/CADo7T4cEGEiga_HoU6MiYVrg5TFtdUx%2BtX73Zg1HYJozosDZSQ%40mail.gmail.com.
>


Johnny Rosenberg

unread,
Dec 25, 2021, 4:12:15 PM12/25/21
to autoke...@googlegroups.com
Den lör 25 dec. 2021 kl 04:23 skrev <jos...@main.nc.us>:
Not sure it really makes a difference in this case, but find and whereis
work completely differently

Yes, of course, otherwise there wouldn't be a reason for it to exist… ;)
 
which explains the timing. One thing that
might make find better for this is that it looks everywhere and tells you
everything it finds whereas whereis will stop on the first executable
match it finds in your PATH. If you have a local copy and a system copy,
it will only find one of them. I'd like to clean out whatever is there for
a fresh start, so find might be better.

Yes, there is a time and place for (almost) everything. :)


Kind regards

Johnny Rosenberg
 

Simon K.

unread,
Dec 27, 2021, 1:52:23 PM12/27/21
to autokey-users
Hi, 

thanks for the help guys. I managed to uninstall and reinstall autokey using apt. 
Now I have version 0.95.1 installed and "Paste using clipboard works" fine, except in some rare instances Autokey does not insert my phrase, but something that I manually copied into my clipboard using CTRL+C keys. Any ideas on that? 

Greetings

Johnny Rosenberg

unread,
Dec 27, 2021, 2:54:30 PM12/27/21
to autoke...@googlegroups.com
Den mån 27 dec. 2021 kl 19:52 skrev Simon K. <ausge...@gmail.com>:
Hi, 

thanks for the help guys. I managed to uninstall and reinstall autokey using apt. 
Now I have version 0.95.1 installed and "Paste using clipboard works" fine, except in some rare instances Autokey does not insert my phrase, but something that I manually copied into my clipboard using CTRL+C keys. Any ideas on that?

If you are using a phrase for that, you can not do much about it, unless you want to edit the actual AutoKey code itself. I guess it could be some kind of timing issue, something like that it pastes before the contents of the clipboard has changed. One workaround is then to write a script instead, in which you can manually set delays, so things are not pasted "too early".

Those things have been discussed many times in this mailing list, so I guess you cold search here for some inspiration.

I usually make a function for typing via clipboard, in which the clipboard and delays are managed. Then, in the main script, you only need to call that function for everything you want to type.



Kind regards

Johnny Rosenberg
 

Simon K.

unread,
Dec 28, 2021, 8:04:02 AM12/28/21
to autokey-users
Think I'll have to live with the delay then. I have 70+ phrases and I am not very good at scripting. Is there any workaround besides using scripts?

Kreezxil

unread,
Dec 28, 2021, 8:29:54 AM12/28/21
to autoke...@googlegroups.com
Try the other two options for the macro (phrase), CTRL+V isn't the only one.

Simon K.

unread,
Dec 28, 2021, 9:36:57 AM12/28/21
to autokey-users
You mean Ctrl+Shift+V or Shift+Insert? Does work either. 
I use those phraes to fill webforms exclusively and this is the case where the clipboard insert does not work. I think the webform is slow to react and by the time it accepts input Autokey already tried to insert the clipboard content and deleted it. 

Kreezxil

unread,
Dec 29, 2021, 10:28:01 AM12/29/21
to autokey-users
These options: these_options.png

Have you tried all of them? The keyboard and mouse selection might work for you too. When I do multi-computer KVM setups using “synergy”, I have to go with keyboard, else the pastes don't work. Scripting isn't hard if you want to do it. There are many keen examples in the wiki that you can copy and paste and change a bit here and there to meet your needs. If you shared a link to the web form, others here can test if that form really is slow, and we might be able to help you design a script that you can use. The community doesn't expect you to learn to program if you don't want to, but you must provide us with enough information to cause a script to materialize.

Message has been deleted

jos...@main.nc.us

unread,
Jan 4, 2022, 5:51:38 PM1/4/22
to autoke...@googlegroups.com
This got stuck in our possible spam folder for some reason. I let it out.

If you need to go really slow, then you need the type_slow() function from
that issue report (#566) I referenced earlier. It lets you set several
delays in the pasting process as long as you want to. Then convert just
one of your phrases to use it. Once that works fine, you can convert more
of them. You could also mass produce the new scripts from a template, but
someone would have to write a new script to do it because scripts are
coded differently than phrases.

Your new script would start with the function definition and then

def type_slow(string1, string2, startdelay=0.0, backdelay=0.0, delay=0.3,
typedelay=0.0):

time.sleep(startdelay)

for c in string1:
keyboard.send_keys("<backspace>")
time.sleep(backdelay)

time.sleep(delay)

for c in string2:
keyboard.send_keys(c)
time.sleep(typedelay)

return

type_slow("", "your big text", 1, 1, 1, 1)

The above script will take ages to run, but it should work fine.
(but copy the function from the issue because emails tend to mess up the
indentation that Python is so particular about.)

Once it works, you can gradually reduce all the "1"s toward 0.1 - one at a
time until it breaks again. Use bisecting: 0.5 ... 0.25 ... going half of
the previous value each time to get the range and then backing off half of
that if it breaks - so you hone in on the needed values as quickly as
possible.

The way the function is called above assumes that either there is no
trigger abbreviation or that the abbreviation is selected before the
script is invoked. If it needs to work a bit differently than that, we can
adjust it.

Joe


> Hey,
> thanks for the help. I tried all of the options but neither did work on the
> webform.
> Unfortunately, I can not give you access to the webform, as I would need to
> give you access to my webaccount.
> The webform looks like that:
> <textarea autocomplete="off" maxlength="1000" rows="3"
> class="el-textarea__inner" style="min-height: 33.2222px;"
> spellcheck="false" data-gramm="false"></textarea>
> but if I try to insert something in there when it is not embedded in the
whole Javascript environment on the webpage, it works fine. Probably the
whole js webform is slow, because there are lots of such forms inside.
What I need to do is following:
> I have a .csv Table with two columns:
> Column A: "abbreviation" (that I use to trigger the phrase)
> Column B: "phrase" (the actual string of text I want autokey to insert
instead of the abbreviation)
> Right now I use a script that a friend of mine coded for me (I already
posted it above). This script takes the values of the csv and creates
.txt
> and .json files that I copy into a Autokey Phraes folder.
> Greetings
> Simon
> On Wednesday, December 29, 2021 at 4:28:01 PM UTC+1 kree...@gmail.com
wrote:
>>>>>>>>> https://groups.google.com/d/msgid/autokey-users/0b39e57c6a23fe8c503b301305b2d15d.squirrel%40www.main.nc.us
.
>>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google
Groups "autokey-users" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
send an email to autokey-user...@googlegroups.com.
>>>>>> To view this discussion on the web visit
>>>>>>> https://groups.google.com/d/msgid/autokey-users/513b29b3-604b-4cad-9aff-0fd0f090de69n%40googlegroups.com
<https://groups.google.com/d/msgid/autokey-users/513b29b3-604b-4cad-9aff-0fd0f090de69n%40googlegroups.com?utm_medium=email&utm_source=footer>
.
>>>>>> --
>>>>> You received this message because you are subscribed to a topic in the
>>>>> Google Groups "autokey-users" group.
>>>>> To unsubscribe from this topic, visit
>>>>> https://groups.google.com/d/topic/autokey-users/XmsZaUdzghQ/unsubscribe
.
>>>>> To unsubscribe from this group and all its topics, send an email to
autokey-user...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/autokey-users/b521239f-3752-45f4-a05f-7d4e67741a6dn%40googlegroups.com
<https://groups.google.com/d/msgid/autokey-users/b521239f-3752-45f4-a05f-7d4e67741a6dn%40googlegroups.com?utm_medium=email&utm_source=footer>
.
> --
> You received this message because you are subscribed to the Google
Groups
> "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
an
> email to autokey-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/111ec23f-ec52-4508-8bb0-35cc6981ceefn%40googlegroups.com.




Simon K.

unread,
Jan 6, 2022, 12:53:58 PM1/6/22
to autokey-users
Thanks Joe.
Reply all
Reply to author
Forward
0 new messages