register imported abbreviations

26 views
Skip to first unread message

hanN...@mailinator.com

unread,
Dec 19, 2018, 10:25:39 PM12/19/18
to autoke...@googlegroups.com
Hello autokey-users,

I've developed a python script to import abbreviations from the osx
typeit4me application into Autokey.
https://www.ettoresoftware.com/mac-apps/typeit4me/

The import generates the corresponding text and JSON files, however in
Autokey abbreviations themselves are not enabled. That is I have to add
the triggering abbreviation in the GUI...

Any ideas why this is? How can I register the imported abbreviations
within AutoKey?

I'm thankful for any hints and tips.

Best Regards,
hanNd2NO

Joe

unread,
Dec 20, 2018, 4:54:45 AM12/20/18
to autoke...@googlegroups.com
Welcome to the list, hanNd2NO.

Before getting into the details, what version of AutoKey are you using?
If it's not 0.95.x, then you should upgrade, if possible, for many reasons.
(I'll provide instructions if that's the case.)

My experience is that you can copy anything into the proper directories
and they just work - if the files are good.
However, they do not show up in the AutoKey Main Menu (if it is open)
unless the menu is closed and reopened.

So, try closing and reopening the Menu after adding your abbreviation files.

If that doesn't work, try closing and restarting AutoKey (making sure
it's gone with something like ps -ef | grep [a]utokey.)

If that still doesn't work, try both steps again, but with an AutoKey
trace running. It probably won't show us anything, but it's worth a try.

In any case, whenever you're trying something new like this, you should
be running AutoKey from a terminal so that you can see any error or
warning messages it issues.

See
https://github.com/autokey/autokey-python2/wiki/Problem-Reporting-Guide
for how to run a trace.

If you post any trace output to this list, etc., please review it first
to assure that there's no sensitive information such as passwords in it.

I am attaching the .txt and .json files from one of my working phrases.
It has a hotkey and a trigger phrase defined.

You can compare them with your generated phrases.

You can also install them on your system to test your installation
procedure.

Just to make sure, what does OS X use for a newline? Is it the same as
Linux - just a linefeed, or a carriage return+linefeed like Windows uses?
Something invisible like that in your files might cause an issue.

If this doesn't either solve it or give us actionable clues, then we'll
have to pursue it with the developers.
(So, save any test results, etc. in case we have to show them to the
developers.)

You could also post one of your phrases (both files  as attachments), I
can see what happens when I try to install them here.

When you do get it to work, it would be great if you could share it with us.

Joe
Phone_Request.txt
.Phone_Request.json

hanN...@mailinator.com

unread,
Dec 20, 2018, 9:07:21 AM12/20/18
to autokey-users, Joe
hello Joe,

Thanks for the quick response.

1. I'm using Autokey 0.95.x

2. So I have the JSON and Text files in the right directories. They do
show in the GUI. I have not run Autokey from the terminal during
development.

3. The issue is the "trigger phrase", which is not triggering for the
imports.
    I have to manually add the trigger phrase in the GUI, then on the
following tries, the expansion is triggered.

So now, i'll try running Autokey from the terminal, optionally running a
trace and compare the output files and report back.
Attached are sample files output by the script

Once it is all working, i share it script.

Best regards
hanNd2NO
*info.json
*info.txt

hanN...@mailinator.com

unread,
Dec 20, 2018, 11:17:10 AM12/20/18
to autokey-users, Joe
hello Joe,

Thanks for the quick response.

1. I'm using Autokey 0.95.x

2. So I have the JSON and Text files in the right directories. They do
show in the GUI. I have not run Autokey from the terminal during
development.

3. The issue is the "trigger phrase", which is not triggering for the
imports.
    I have to manually add the trigger phrase in the GUI, then on the
following tries, the expansion is triggered.

So now, i'll try running Autokey from the terminal, optionally running a
trace and compare the output files and report back.
Attached are sample files output by the script

Once it is all working, i share it script.

Best regards
hanNd2NO

On 20.12.18 10:54, Joe wrote:
*info.json
*info.txt

Joe

unread,
Dec 20, 2018, 11:49:22 AM12/20/18
to autoke...@googlegroups.com
I'm running pretty slow at the moment, so I probably made some mistakes.

I couldn't get your phrase to work at all - but that may be because of
the above.

I wrote my own in the AutoKey window and it works - attached.

A couple of comments:

Naming things and setting abbreviations to strings which include Linux
metacharacters is legal, but asking for trouble.

*info - would be expanded by the shell in a terminal window (I know you
used a window filter) and -info would be an options string to many
commands (unless you precede it with a -- , a ./, etc.)

I don't know much about json, but I'm sure it works in a compressed
format, but if you ever have to read it, you'll be way better off if
it's "pretty printed"/formatted  like the ones AutoKey generates. I'm
sure there's a Python function for something simple like that.

I wrote a proof of concept bash script to convert an AutoHotKey phrase
to an AutoKey phrase. (It ignores almost all of the AutoHotKey options.)
I took a json file from an existing phrase and put placeholders where I
needed to insert variable values, so I got all the pretty formatting for
free.

Since I can't see anything wrong with what you're doing (aside from the
small detail that it doesn't work), I recommend you head over to Gitter
and talk directly with the developers. https://gitter.im/autokey/autokey

I'm over there too, so I'll see what you figure out.

Joe
.infoj.json
infoj.txt

Steve Anderson

unread,
Jan 13, 2020, 4:46:01 PM1/13/20
to autokey-users
Hi.

Did this ever get resolved? I am attempting a similar migration of hundreds of abbreviations/phrases that I have been using in aText on Mac and AsUType on Windows for years. If I have to set the abbreviation for each of these manually, it will be literally days of effort to get me to a usable baseline.

As an example, because I use the text substitution effectively to type in shorthand most of my day, the two sentences I have written above would have expanded 8 phrases already. That saves me literally hours a week of typing effort, not to mention all the other benefits of boilerplate text substitution etc.

Writing and running a script to take my existing data and produce the relevant .json and .txt files is almost trivial by comparison.

Hopefully someone can put me right ?

Many Thanks,
Steve.

jack horsfield

unread,
Jan 13, 2020, 4:50:23 PM1/13/20
to autoke...@googlegroups.com
Out of the box...

It's probably possible to write a script that reads a file of abbreviations and then drives the autokey UI to define them in autokey.

But i leave the real answer to Joe. I'm not hopeful.

Steve Anderson

unread,
Jan 13, 2020, 5:04:00 PM1/13/20
to autokey-users
Thanks for the response but I have just found the reason for the problem I was having.

I was creating foo.json and foo.txt files in the config directory.

Autokey creates (and then obviously looks for) hidden JSON files - which have a filename beginning with a dot.

I changed my script to create .foo.json and foo.txt and bingo! it works. ran a couple of tests to confirm it and I am now confident I can get up to speed with Autokey within the next few days.

Hope this is helpful to others.

Cheers,
Steve.

jack horsfield

unread,
Jan 13, 2020, 5:05:38 PM1/13/20
to autoke...@googlegroups.com
Fantastic. One happy ending.

Joe

unread,
Jan 13, 2020, 7:34:14 PM1/13/20
to autoke...@googlegroups.com
The AutoKey API has functions for creating new abbreviations and
hotkeys, but I've never seen anyone use them except to make sure they
work. They probably wouldn't help with this anyway.

You can just have an external program (like I did with my AutoHotKey
phrase converter) or like the new Python script in a related post in
this thread.

The only trick is getting AutoKey to display them in its main window.
Sometimes, just closing and opening the window does it and sometimes you
have to completely exit AutoKey and restart it to get the new phrases
(or scripts) to be displayed (although they do seem to work immediately
when triggered even if you can't see them in the GUI.) See
https://github.com/autokey/autokey/issues/353

Joe

On 1/13/20 4:50 PM, jack horsfield wrote:
> Out of the box...
>
> It's probably possible to write a script that reads a file of
> abbreviations and then drives the autokey UI to define them in autokey.
>
> But i leave the real answer to Joe. I'm not hopeful.
> On 13 Jan 2020, at 21:46, Steve Anderson <stev...@gmail.com
> --
> 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
> <mailto:autokey-user...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/6179e002-fd9a-4349-8582-c186fce3303f%40gmail.com
> <https://groups.google.com/d/msgid/autokey-users/6179e002-fd9a-4349-8582-c186fce3303f%40gmail.com?utm_medium=email&utm_source=footer>.

Joe

unread,
Jan 13, 2020, 7:41:42 PM1/13/20
to autoke...@googlegroups.com
Very glad you got your issue resolved.

When you're happy with your Python script, please consider adding it to
our wiki so others can use it too. It doesn't have to be polished/"end
user quality" as long as someone can use it as a jumping off point for
their needs.

Also, see https://github.com/autokey/autokey/issues/337 - a request I
made to unhide these files so problems like this don't happen to start with.

Joe

On 1/13/20 5:03 PM, Steve Anderson wrote:
> Thanks for the response but I have just found the reason for the
> problem I was having.
>
> I was creating foo.json and foo.txt files in the config directory.
>
> Autokey creates (and then obviously looks for) hidden JSON files -
> which have a filename beginning with a dot.
>
> I changed my script to create .foo.json and foo.txt and bingo! it
> works. ran a couple of tests to confirm it and I am now confident I
> can get up to speed with Autokey within the next few days.
>
> Hope this is helpful to others.
>
> Cheers,
> Steve.
>
> On Monday, 13 January 2020 21:50:23 UTC, jack wrote:
>
> Out of the box...
>
> It's probably possible to write a script that reads a file of
> abbreviations and then drives the autokey UI to define them in
> autokey.
>
> But i leave the real answer to Joe. I'm not hopeful.
> On 13 Jan 2020, at 21:46, Steve Anderson <stev...@gmail.com
> --
> 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
> <mailto:autokey-user...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/b40fac80-b4bf-4ffb-bb0e-f6f0460e6a68%40googlegroups.com
> <https://groups.google.com/d/msgid/autokey-users/b40fac80-b4bf-4ffb-bb0e-f6f0460e6a68%40googlegroups.com?utm_medium=email&utm_source=footer>.

GMX

unread,
Jan 25, 2020, 9:42:49 AM1/25/20
to autoke...@googlegroups.com
Hello,

I tried my set of phrases on multiple machines, so I copied the
~/.config/autokey directory on my owncloud and set a link
to wd/.config/. Did the same on remote machines, but it works only on
the first one.  

Does AK need more than just the text files I can see? - Any special
tricks required?

Cheers, 
Wolf

Joe

unread,
Jan 25, 2020, 12:02:34 PM1/25/20
to autoke...@googlegroups.com
Welcome to the list, GMX.

Yep, you have to copy all the hidden files too (which rsync will do by
default, but cp and most other things won't.) Each phrase and script has
a hidden sidecar json file that contains all the metadata/settings for
the phrase/script like its hotkey, window filter ... (I have an issue
filed for unhiding them because we run into this all the time.)

Examples:

myphrase.txt has .myphrase.json and myscript.py has .myscript.json (The
leading . makes files hidden on Linux by default.)

Also, AutoKey doesn't "watch" its folders, so after you manually change
anything in them (like moving or renaming files or folders from outside
of AutoKey), the changes "may" become available immediately, but they
definitely won't show up in the main window. If you completely exit
AutoKey and restart it, it will rescan its folders and see all the changes.

BTW, when you define a new folder using the AutoKey main window, it
gives you the option of specifying any path you want. You don't need to
use symlinks (although they're fine.) One word of caution: DON'T DO THIS
with an EXISTING FOLDER full of scripts and phrases. AutoKey will delete
them. You need to create an empty folder using AutoKey and then copy
your phrases/scripts into it. The folder can contain subfolders.
(There's another issue filed to fix this and I believe it's already
fixed in development for 0.96, but there's no planned release date for
that yet.)

I've been doing it this way for years. It makes accessing and backing up
my scripts/phrases more convenient and has the added benefit that if you
update or even purge AutoKey while upgrading, etc., none of your work
gets deleted.

Where symlinks shine is if you want to have multiple AutoKey
environments. You just point the symlink(s) to new (sub)sets of phrases
and scripts and restart AutoKey. Then all your "new" definitions are
available.

Joe

Herr Oswald

unread,
Jan 28, 2020, 8:06:00 AM1/28/20
to autoke...@googlegroups.com
Thank you very much for your detailed answer.
Yes, this explains very well, why my approach to share AK phrases does
not work: owncloud by default ignores hidden files.

Now, instead of investigating a way to get hidden files synced just in
one directory (which is not just easy.going), I ask myself (and you):
Does it make sense to have hidden files in a hidden folder?

AFAIK, this is done very rarely, mainly for temporary files which a
user will normally not edit. My idea of hidden folders is that there
things are hidden which are not for everybody, only for people who know
what they are doing. So why should we hide files "everybody" would not
find anyway?

Cheers,
Wolf

Joe

unread,
Jan 29, 2020, 12:32:18 AM1/29/20
to autoke...@googlegroups.com
I have filed an issue to unhide them.

Just a guess: Since there are two of everything in the phrase and script
folders, hiding the json files just gets rid of clutter - especially
since a "normal" user should never need to look at or modify these files.

I don't use owncloud, but a quick search turned this up:

https://askubuntu.com/questions/942630/how-to-synchronize-hidden-dot-files-in-owncloud-nextcloud

It's over two years old, but it's worth trying to see if it still works.

Joe

Herr Oswald

unread,
Jan 29, 2020, 1:32:04 AM1/29/20
to autoke...@googlegroups.com
Am Mittwoch, den 29.01.2020, 00:32 -0500 schrieb Joe:
> I have filed an issue to unhide them.

Thank you, I think this is the way to go.

> Just a guess: Since there are two of everything in the phrase and
> script
> folders, hiding the json files just gets rid of clutter - especially
> since a "normal" user should never need to look at or modify these
> files.
>
> I don't use owncloud, but a quick search turned this up:
>
>
https://askubuntu.com/questions/942630/how-to-synchronize-hidden-dot-files-in-owncloud-nextcloud

You can easily do in in the GUI, but only system wide, which I do not
really want. And finding a solution for all the other cloud services
around is annoying as well.

So IMHO visible config files are really a good idea, thank for your
agreement.

Cheers,
Wolf
Reply all
Reply to author
Forward
0 new messages