problem with abbreviation

36 views
Skip to first unread message

Albrecht Mehl

unread,
Apr 12, 2022, 5:18:13 AM4/12/22
to autoke...@googlegroups.com
Autokey 0.95.9 has been newly installed on opensuse linux 15.3., kde.

As of now it should be used only for inserting preselected phrases.

As an example the abbreviation and hotkey

n Albrecht Mehl F8

were chosen. So I would like to write

my name is n<F8> and get

my name is Albrecht Mehl

BUT whatever the preferences are this does not work, e.g. the 'n' is not
erased even though 'Remove typed abbreviation' is checked. So I would be
very thankfull to get the exact settings for the set abbreviations
window for my simple needs. So far my choice is

Trigger on all non-word
Only 'remove typed abbreviation' checked

There is no need for using the case of the typed abbrevition.

Probably my question is a very simple one ... but I cannot help.

Albrecht

Joe

unread,
Apr 15, 2022, 4:48:54 AM4/15/22
to autokey-users
I think the issue here is that it's hotkey "or" abbreviation, not hotkey "and" abbreviation. The two don't work in conjunction.

The simplest approach would be to assign a hotkey such as <super>+n or <super>+<F8> to your phrase and/or an abbreviation such as "!n". Either would work by itself and both are fairly unlikely to occur "in nature" to trigger the phrase when it is undesired.

Always try your hotkey by itself before using it in AutoKey to make sure it's not already assigned to do something else in your system. The newer versions of KDE assign a ton of hotkey combinations to relatively obscure functions and KDE usually gets priority over AutoKey as to who owns a hotkey.

Also, if you only want your phrase (or script) to work in certain applications, you can set the window filter option to match the class OR title of the respective windows. That's a bit trickier to get right, so ask about that if it's appropriate for your situation.

If you need more complex triggering or other behavior, you will have to switch from a phrase to a script, but implementing triggers that depend on sequential actions of any type gets complex pretty quickly unless you don't mind  responding to a pop-up dialog of some sort.

On another note, 0.95.10 has been out for around two years, so you should see if that is available via OpenSuse. It has some bug fixes, etc.

If you are a bit adventurous, you can install 0.95.10 using pip with instructions here.

We also have an enhanced new version, 0.96.0 Beta 10 which, as the name suggests, is still a beta release, but it's quite stable and we'd really appreciate feedback from someone using it on OpenSuse. It contains a lot of bug fixes and several new features.

Joe

Johnny Rosenberg

unread,
Apr 15, 2022, 5:24:43 PM4/15/22
to autoke...@googlegroups.com
Den fre 15 apr. 2022 kl 10:48 skrev Joe <jos...@main.nc.us>:
I think the issue here is that it's hotkey "or" abbreviation, not hotkey "and" abbreviation. The two don't work in conjunction.

The simplest approach would be to assign a hotkey such as <super>+n or <super>+<F8> to your phrase and/or an abbreviation such as "!n". Either would work by itself and both are fairly unlikely to occur "in nature" to trigger the phrase when it is undesired.

Always try your hotkey by itself before using it in AutoKey to make sure it's not already assigned to do something else in your system. The newer versions of KDE assign a ton of hotkey combinations to relatively obscure functions and KDE usually gets priority over AutoKey as to who owns a hotkey.

Also, if you only want your phrase (or script) to work in certain applications, you can set the window filter option to match the class OR title of the respective windows. That's a bit trickier to get right, so ask about that if it's appropriate for your situation.

If you need more complex triggering or other behavior, you will have to switch from a phrase to a script, but implementing triggers that depend on sequential actions of any type gets complex pretty quickly unless you don't mind  responding to a pop-up dialog of some sort.

On another note, 0.95.10 has been out for around two years, so you should see if that is available via OpenSuse. It has some bug fixes, etc.

If you are a bit adventurous, you can install 0.95.10 using pip with instructions here.

We also have an enhanced new version, 0.96.0 Beta 10 which, as the name suggests, is still a beta release, but it's quite stable and we'd really appreciate feedback from someone using it on OpenSuse. It contains a lot of bug fixes and several new features.

Joe


On Tuesday, April 12, 2022 at 5:18:13 AM UTC-4 Albrecht Mehl wrote:
Autokey 0.95.9 has been newly installed on opensuse linux 15.3., kde.

As of now it should be used only for inserting preselected phrases.

As an example the abbreviation and hotkey

n Albrecht Mehl F8

What does this mean? What's the n doing there and is F8 the trigger key?
 

were chosen. So I would like to write

my name is n<F8> and get

my name is Albrecht Mehl

Ah, so n F8 is your trigger combination?
Sure, that can be done with some tricks, but not with a phrase. You need to write a script.
 

BUT whatever the preferences are this does not work, e.g. the 'n' is not
erased even though 'Remove typed abbreviation' is checked.

I would like to see your actual settings. How do you set a phase to trigger to n<F8>? I'm pretty sure that can't be done with a phrase.
 
So I would be
very thankfull to get the exact settings for the set abbreviations
window for my simple needs. So far my choice is

Trigger on all non-word
Only 'remove typed abbreviation' checked

There is no need for using the case of the typed abbrevition.

Probably my question is a very simple one ... but I cannot help.

Albrecht

I would write a script that trigger to F8. The first thing that script would do is to do a Shift+← Ctrl+c, then read the clipboard. If the clipboard contains an n, do a delete (to delete the n), then type your name.

I'll actually try to do it right now…

Okay, after some experimenting I came up with this script, which I linked to F8:

# First, a function for sending via the clipboard:
def SendViaClipboard(sText):
    # Fill the clipboard and paste it.
    clipboard.fill_clipboard(sText)
    keyboard.send_keys("<ctrl>+v")
    time.sleep(0.1)

# Remember the original clipboard content.
OriginalClipboard=clipboard.get_clipboard()

# Abbreviations:
Dict={'a': "Autokey",
      'x': "the letter x",
      'p': "℗",
      'n': "Johnny Rosenberg"}

# Do the actual work.
keyboard.send_keys("<shift>+<left>")
keyboard.send_keys("<ctrl>+c")
time.sleep(0.3)
keyboard.send_keys("<delete>")
sText=clipboard.get_clipboard()
SendViaClipboard(Dict[sText])

# Reset the clipboard to its original state.
clipboard.fill_clipboard(OriginalClipboard)

Note that I print using the clipboard. That is not needed in most cases, but I prefer it because it will less likely be any problems using Unicode specific characters, such as the ℗ for ”p F8”. When using the clipboard this way, you also need to add some delays making sure the clipboard is not read before the content changed (it takes some time) and things like that, so if problems occurs, try to experiment with those time.sleep() statements. The numbers in the example above at least work for me on my specific computer, but maybe not on all computers out there, unless some delays are changed.

Anyway, I use a dictionary to get this done, so it's easy to edit the script for your needs. Just add more lines to Dict={}.
You can even associate words with other words, but then you need to change the <Shift>+<left> to <Shift>+<Ctrl>+<left>, highlighting a whole word rather than just one character.

Here's my test that I do live while writing this email, using the exact script above:
My name is Johnny Rosenberg.
I will now type the letter x.
This is a Unicode character that's usually not included on a keyboard: ℗.
I love Autokey.

Seems to work very well on my computer, at least in Firefox in which I'm logged in to Gmail writing this, but probably in most situations and software, except in terminal emulators that use Ctrl+Shift+c and Ctrl+Shift+v for copy and paste, but maybe terminal emulators isn't where AutoKey is needed the most anyway.

If you're not familiar with Python, maybe I'd better add that in Python indents are very important. I don't know if those included here in this message will make it all the way to this list. If not, you need to add them yourself. I think four spaces or a Tab per indent usually works, but you can not mix them. If you start using four spaces you will need to use four spaces for every indent. I'm not very good at Python, so this is only what others told me at some point. I always have to look up everything when I write Python scripts.


Anyway, I hope this helps in some way or another.



Kind regards

Johnny Rosenberg
 

--
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/d40c0652-9a65-48d2-8fee-77f3cf6d69cbn%40googlegroups.com.

Albrecht Mehl

unread,
Apr 16, 2022, 10:14:44 AM4/16/22
to autoke...@googlegroups.com
Thank you very much for your reply.

Am 15.04.22 um 10:48 schrieb Joe:
> I think the issue here is that it's hotkey "or" abbreviation, not hotkey
> "and" abbreviation. The two don't work in conjunction.

From the user program kile for the type setting program latex I was
used the way I described in my post:

- to each phrase you assign a unique shortcut, usually 1 to 3 digits
- choose one and only one trigger key for _all_ phrases
- to have the phrase inserted you first write the shortcut
and start the erasing of the shortcut and the immediate
following inserting of the phrase by hitting the trigger key

So I hope you will forgive me mixing up hotkey and abbreviation. In the
autokey manual I had not understood the difference as it seemed - at
least to me - not very clearly explained.

> The simplest approach would be to assign a hotkey such as <super>+n or
> <super>+<F8> to your phrase and/or an abbreviation such as "!n". Either
> would work by itself and both are fairly unlikely to occur "in nature" to
> trigger the phrase when it is undesired.

As I have written I use opensuse linux 15.3, kde. Even though I looked
in the net I could not find _exactly_ what super means, i.e. how I
assign a key - e.g. the windows key - to be the super key.

As for your recommendation to use the actual version of autokey: I used
a .rpm file to install it. For a long time there was no rpm for opensuse
at all ... so one has to be satisfied with the file which is offered
now. Of course in case you know a newer rpm file for my opensuse linux I
would be very grateful to get the corresponding link.

A. Mehl
--
eAdresse = mehlBEIiesyPUNKTnet
Veilchenweg 7, 64291 Darmstadt (Germany) Tel. (06151) 37 39 92
1 kWh ⩯ 0,5 kg Steinkohle ⩯ 1,5 kg CO2
1 W dauernd 7/24 ≈ 10 kWh/Jahr ⩯ 5 kg Steink./Jahr ⩯ 15 kg CO2/Jahr





jos...@main.nc.us

unread,
Apr 20, 2022, 2:08:45 AM4/20/22
to autoke...@googlegroups.com
I didn't check it out in detail, but your script looks very nice!

Joe
>> <https://github.com/autokey/autokey/wiki/Installing#pip-installation>.
>>
>> We also have an enhanced new version, 0.96.0 Beta 10 which, as the name
>> suggests, is still a beta release, but it's quite stable and we'd really
>> appreciate feedback from someone using it on OpenSuse. It contains *a
>> lot*
> *# First, a function for sending via the clipboard:*
>
>
>
>
>
>
>
>
> *def SendViaClipboard(sText): # Fill the clipboard and paste it.
> clipboard.fill_clipboard(sText) keyboard.send_keys("<ctrl>+v")
> time.sleep(0.1)# Remember the original clipboard
> content.OriginalClipboard=clipboard.get_clipboard()*
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *# Abbreviations:Dict={'a': "Autokey", 'x': "the letter x", 'p':
> "℗", 'n': "Johnny Rosenberg"}# Do the actual
> work.keyboard.send_keys("<shift>+<left>")keyboard.send_keys("<ctrl>+c")time.sleep(0.3)keyboard.send_keys("<delete>")sText=clipboard.get_clipboard()SendViaClipboard(Dict[sText])#
> Reset the clipboard to its original
> state.clipboard.fill_clipboard(OriginalClipboard)*
>
> Note that I print using the clipboard. That is not needed in most cases,
> but I prefer it because it will less likely be any problems using Unicode
> specific characters, such as the ℗ for ”p F8”. When using the clipboard
> this way, you also need to add some delays making sure the clipboard is
> not
> read before the content changed (it takes some time) and things like that,
> so if problems occurs, try to experiment with those time.sleep()
> statements. The numbers in the example above at least work for me on my
> specific computer, but maybe not on all computers out there, unless some
> delays are changed.
>
> Anyway, I use a dictionary to get this done, so it's easy to edit the
> script for your needs. Just add more lines to Dict={}.
> You can even associate words with other words, but then you need to change
> the <Shift>+<left> to <Shift>+<Ctrl>+<left>, highlighting a whole word
> rather than just one character.
>
> Here's my test that I do live while writing this email, using the exact
> script above:
> *My name is Johnny Rosenberg.*
> *I will now type the letter x.*
> *This is a Unicode character that's usually not included on a keyboard:
> ℗.*
> *I love Autokey.*
>> <https://groups.google.com/d/msgid/autokey-users/d40c0652-9a65-48d2-8fee-77f3cf6d69cbn%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/CADo7T4e84ofR%2BmW%2BuR9cU4a%2BBAj-t1mDikgsxpj35g81mieSNw%40mail.gmail.com.
>


jos...@main.nc.us

unread,
Apr 20, 2022, 2:51:51 AM4/20/22
to autoke...@googlegroups.com
We don't really have an AutoKey "manual", but there's a lot of material in
our wiki at https://github.com/autokey/autokey/wiki .

We need feedback from all levels of users to improve it, so if you have
any specific suggestions or want to contribute any content, please feel
free.

AutoKey does not work the way kile apparently does, but Johnny's script
looks like it will either do exactly what you want or can be modified to
do so. We can help with that if you can try it out and tell us what
changes, if any, are needed.

The "Super" key is the "non-Windows" name for the Windows key. It's there
on most keyboards. AutoKey treats it as a modifier key, similar to the
Shift key. When you assign a hotkey to a script or phrase, you can click
on the Record a key combination button and then press and hold one or more
modifier keys (including Super) along with another non-modifier key (and
then release them all) to set that key combination as the hotkey which
will activate that script/phrase. You just have to make sure that nothing
else was already assigned to that combination. (There are some exceptions
and fine points to this, but I don't want to complicate this explanation.)

An abbreviation is a (hopefully unique) text string. When one is assigned
to a script or phrase, AutoKey notices when you type it and invokes your
script or phrase. Exactly how the abbreviation starts to trigger the
invocation is modified by several options. Usually, typing a space or tab
after the abbreviation causes it to trigger the associated action, but it
can be set to trigger immediately and you can choose whether or not the
abbreviation will be removed before the action is invoked as well as a few
other options.

Joe

> Thank you very much for your reply.
> Am 15.04.22 um 10:48 schrieb Joe:
>> I think the issue here is that it's hotkey "or" abbreviation, not
hotkey
>> "and" abbreviation. The two don't work in conjunction.
> From the user program kile for the type setting program latex I was
> used the way I described in my post:
> - to each phrase you assign a unique shortcut, usually 1 to 3 digits
- choose one and only one trigger key for _all_ phrases
> - to have the phrase inserted you first write the shortcut
> and start the erasing of the shortcut and the immediate
> following inserting of the phrase by hitting the trigger key
> So I hope you will forgive me mixing up hotkey and abbreviation. In the
autokey manual I had not understood the difference as it seemed - at least
to me - not very clearly explained.
>> The simplest approach would be to assign a hotkey such as <super>+n or
<super>+<F8> to your phrase and/or an abbreviation such as "!n". Either
would work by itself and both are fairly unlikely to occur "in nature" to
>> trigger the phrase when it is undesired.
> As I have written I use opensuse linux 15.3, kde. Even though I looked
in the net I could not find _exactly_ what super means, i.e. how I assign
a key - e.g. the windows key - to be the super key.
> As for your recommendation to use the actual version of autokey: I used
a .rpm file to install it. For a long time there was no rpm for opensuse
at all ... so one has to be satisfied with the file which is offered now.
Of course in case you know a newer rpm file for my opensuse linux I would
be very grateful to get the corresponding link.
> A. Mehl
> --
> eAdresse = mehlBEIiesyPUNKTnet
> Veilchenweg 7, 64291 Darmstadt (Germany) Tel. (06151) 37 39 92 1 kWh
⩯ 0,5 kg Steinkohle ⩯ 1,5 kg CO2
> 1 W dauernd 7/24 ≈ 10 kWh/Jahr ⩯ 5 kg Steink./Jahr ⩯ 15 kg CO2/Jahr --
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/97b3d263-09fe-f713-e05f-9eefd284b1d0%40gmail.com.








Little Girl

unread,
Apr 24, 2022, 8:16:10 PM4/24/22
to autokey-users
Hey there,

If all else fails, you could use a little hack to get around the issue. Instead of using "Albrecht Mehl" as contents of the phrase, use "<backspace>Albrecht Mehl" as the contents of the phrase. The phrase will then do a backspace first to get rid of that pesky n before pasting in the name.
Reply all
Reply to author
Forward
0 new messages