Using Autokey to send the Ubuntu Compose and characters to generate an mdash

481 views
Skip to first unread message

Ineuw

unread,
Oct 18, 2014, 2:52:40 AM10/18/14
to autoke...@googlegroups.com
This post is related to an earlier post by Mpaa. We are both Wikisource/Wikipedia editors struggling to use Autokey to insert an mdash and other UTF-8 keys in general. I assigned the Compose (aka Superkey) to the Left Windows key on my (standard US) keyboard.

Pressing and releasing the compose key and tapping the - (minus) key (on top of the keyboard) three times in quick succession, generates the mdash, —. Except I don't know the key name for the left windows key and the down and release action. Is this possible?

mdash = "<leftwindn>"+"<leftwinup>"+"-"+"-"+"-"
keyboard.send_keys(mdash)




Johnny Rosenberg

unread,
Oct 18, 2014, 12:29:47 PM10/18/14
to autoke...@googlegroups.com
What's wrong with ”keyboard.send_keys("—")”?

Or just create a phrase and enter an m-dash (–—) there.


My own method for inserting the most common ”special characters” is to use my own keyboard layout. I did it by editing three configuration files. I have ”—” at AltGr+Shift+- and ”–” at AltGr+-. AltGr is missing on US keyboards, I think, but the right Alt key can be used, as far as I heard.


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.
For more options, visit https://groups.google.com/d/optout.

Ineuw

unread,
Oct 18, 2014, 1:54:35 PM10/18/14
to autoke...@googlegroups.com
Something tells me that you haven't tried it. :-).

Johnny Rosenberg

unread,
Oct 18, 2014, 2:59:18 PM10/18/14
to autoke...@googlegroups.com
2014-10-18 19:54 GMT+02:00 Ineuw <in...@aei.ca>:
Something tells me that you haven't tried it. :-).

On Saturday, October 18, 2014 12:29:47 PM UTC-4, Johnny Rosenberg wrote:
2014-10-18 8:52 GMT+02:00 Ineuw <in...@aei.ca>:

This post is related to an earlier post by Mpaa. We are both Wikisource/Wikipedia editors struggling to use Autokey to insert an mdash and other UTF-8 keys in general. I assigned the Compose (aka Superkey) to the Left Windows key on my (standard US) keyboard.

Pressing and releasing the compose key and tapping the - (minus) key (on top of the keyboard) three times in quick succession, generates the mdash, —. Except I don't know the key name for the left windows key and the down and release action. Is this possible?

mdash = "<leftwindn>"+"<leftwinup>"+"-"+"-"+"-"
keyboard.send_keys(mdash)

What's wrong with ”keyboard.send_keys("—")”?

Or just create a phrase and enter an m-dash (–—) there.


My own method for inserting the most common ”special characters” is to use my own keyboard layout. I did it by editing three configuration files. I have ”—” at AltGr+Shift+- and ”–” at AltGr+-. AltGr is missing on US keyboards, I think, but the right Alt key can be used, as far as I heard.


Kind regards

Johnny Rosenberg
ジョニー・ローゼンバーグ

Well, unicode characters works sometimes and sometimes not.
Right now I'm writing this in Gmail using Chrome and it seems to work. My abbreviation is --- and here's the result, I'll try it four times tight now:





I tried earlier in a text exitor called LeafPad, and the result was that AutoKey crashed every time… so something is wrong, but I'm not sure what.

I modified AutoKey according to what was written about this earlier in a thread about Unicode problems.

My signature is also done with AutoKey (the Japanese thing is supposed to be my name, at least according to Google Translate):



Kind regards

Johnny Rosenberg
ジョニー・ローゼンバーグ

P.S. I tried it once again in LeafPad and now the — thing worked but my signature crashed AutoKey. Something is not right, at least… Doesn't feel very stable if you ask me. Either it should never work or it should work every time. Working some times and some times not makes debugging so much harder… D.S.

Johnny Rosenberg

unread,
Oct 18, 2014, 3:00:47 PM10/18/14
to autoke...@googlegroups.com
2014-10-18 20:59 GMT+02:00 Johnny Rosenberg <gurus....@gmail.com>:
2014-10-18 19:54 GMT+02:00 Ineuw <in...@aei.ca>:
Something tells me that you haven't tried it. :-).

On Saturday, October 18, 2014 12:29:47 PM UTC-4, Johnny Rosenberg wrote:
2014-10-18 8:52 GMT+02:00 Ineuw <in...@aei.ca>:

This post is related to an earlier post by Mpaa. We are both Wikisource/Wikipedia editors struggling to use Autokey to insert an mdash and other UTF-8 keys in general. I assigned the Compose (aka Superkey) to the Left Windows key on my (standard US) keyboard.

Pressing and releasing the compose key and tapping the - (minus) key (on top of the keyboard) three times in quick succession, generates the mdash, —. Except I don't know the key name for the left windows key and the down and release action. Is this possible?

mdash = "<leftwindn>"+"<leftwinup>"+"-"+"-"+"-"
keyboard.send_keys(mdash)

What's wrong with ”keyboard.send_keys("—")”?

Or just create a phrase and enter an m-dash (–—) there.


My own method for inserting the most common ”special characters” is to use my own keyboard layout. I did it by editing three configuration files. I have ”—” at AltGr+Shift+- and ”–” at AltGr+-. AltGr is missing on US keyboards, I think, but the right Alt key can be used, as far as I heard.


Kind regards

Johnny Rosenberg
ジョニー・ローゼンバーグ

Well, unicode characters works sometimes and sometimes not.
Right now I'm writing this in Gmail using Chrome and it seems to work. My abbreviation is --- and here's the result, I'll try it four times 
tight now:

He he he… bad spelling… RIGHT now, not ”tight now”… :P

Ineuw

unread,
Oct 18, 2014, 4:34:03 PM10/18/14
to autoke...@googlegroups.com
Johnny, thanks for your replies. I tried google, + opera + firefox, all installed for testing, and none worked. Perhaps you can post a link for the keyboard syntax of Autokey? Typing three hyphens is the keycode in .XCompose file with a superkey. I have spent the past week learning Linux + X +Ubuntu keyboard/character issues to understand. Another question, please. Is there a way, or a software to implement Windows Alt+Numkeypad ANSI character assignments in Ubuntu? At least those I know those by heart.

Joe

unread,
Oct 19, 2014, 12:31:45 AM10/19/14
to autoke...@googlegroups.com
I'm not sure which version of AutoKey either one of you are using, but
there were some fixes for unicode issues in 0.90.4.1 and I believe there
is at least one more being tested. (IIRC, Johnny may have most or all of
these fixes in the version he is running.)

0.90.4.1 is available in our PPA for Ubuntu 14.04 and from source in
git. If you want to pursue this, I will provide more details. Let us
know the name/version of your distro, desktop manager, and AutoKey.

Joe

On 10/18/2014 04:34 PM, Ineuw wrote:
> Johnny, thanks for your replies. I tried google, + opera + firefox,
> all installed for testing, and none worked. Perhaps you can post a
> link for the keyboard syntax of Autokey? Typing three hyphens is the
> keycode in .XCompose file with a superkey. I have spent the past week
> learning Linux + X +Ubuntu keyboard/character issues to understand.
> Another question, please. Is there a way, or a software to implement
> Windows Alt+Numkeypad ANSI character assignments in Ubuntu? At least
> those I know those by heart.
>
> On Saturday, October 18, 2014 2:59:18 PM UTC-4, Johnny Rosenberg wrote:
>
> 2014-10-18 19:54 GMT+02:00 Ineuw <in...@aei.ca <javascript:>>:
> <https://groups.google.com/d/optout>.
>
>
> --
> 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
> <javascript:>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
> --
> 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>.

Ineuw

unread,
Oct 19, 2014, 12:53:51 AM10/19/14
to autoke...@googlegroups.com

Thanks again. I can't speak for Mpaa, but I am using 0.90.4.1. Just installed it a day before my first post. If it works, I am in contact with Mpaa, and let him know.

Johnny Rosenberg

unread,
Oct 19, 2014, 6:44:38 AM10/19/14
to autoke...@googlegroups.com
2014-10-18 22:34 GMT+02:00 Ineuw <in...@aei.ca>:
Johnny, thanks for your replies. I tried google, + opera + firefox, all installed for testing, and none worked. Perhaps you can post a link for the keyboard syntax of Autokey? Typing three hyphens is the keycode in .XCompose file with a superkey. I have spent the past week learning Linux + X +Ubuntu keyboard/character issues to understand. Another question, please. Is there a way, or a software to implement Windows Alt+Numkeypad ANSI character assignments in Ubuntu? At least those I know those by heart.

No, but you can enter the Unicodes directly:
Ctrl+Shift+u
Release keys
Enter the Unicode (in hexadecimal)
Press Enter or Space or something similar.
For instance:
Ctrl+Shift+u 2014 ↵ ⇒ —
Ctrl+Shift+u 205d ↵ ⇒ ⁝
Ctrl+Shift+u 205e ↵ ⇒ ⁞

This won't work in the Opera web browser, at least not in the pre-Chromium one, but that doesn't mean the feature is missing. In Opera you enter the code first, then Ctrl+Shift+x.

There is also a character map installed by default: gnucharmap. In old Gnome 2 there was a character panel thingy that was easy to use, but unfortunately everything good with Ubuntu was removed since version 10.10. Really. Everything. I think they spied on me to find out what applications and features I used the most and then removed them, one by one. That HAS to be the case, there is no other explanation. They just hate me.

Anyway, the character map is still there, maybe because I don't use it very much, and you can use it for searching for special characters, determining their code (such as 2014 for the emdash) and things like that.

Ineuw

unread,
Oct 19, 2014, 4:50:28 PM10/19/14
to autoke...@googlegroups.com
Google group forum post access is so strange from other forums. It took awhile to get to this post. I know the compose key, which is in my case the left win key. I works fine to create symbols from non-numeric keystrokes but not from Unicode numbers — This was created by Win + 3 hyphens in quick succession. It works in the latest Opera as well. But Lwin + 2014 or Lwin + u 2014 doesn't work.

Also, I have no interest to memorize Unicode numbers and use 3 key combinations to enter the variety of characters I deal with. I have the latest Gnome character map as well, The issue here is to save time, when proofreading. I prefer and hope that Autokey can do the job eventually.

Johnny Rosenberg

unread,
Aug 19, 2021, 3:21:14 PM8/19/21
to autoke...@googlegroups.com
Den sön 19 okt. 2014 kl 22:50 skrev Ineuw <in...@aei.ca>:
Google group forum post access is so strange from other forums. It took awhile to get to this post. I know the compose key, which is in my case the left win key. I works fine to create symbols from non-numeric keystrokes but not from Unicode numbers — This was created by Win + 3 hyphens in quick succession. It works in the latest Opera as well. But Lwin + 2014 or Lwin + u 2014 doesn't work.

Did you try to simulate the Ctrl+Shift+u method in Autokey? It seems to work for me, at least:

# Types a — character.
UniCode="2014"
keyboard.send_keys("<ctrl>+<shift>+u")
time.sleep(0.1)
keyboard.send_keys(UniCode)
keyboard.send_keys(" ")


Result:

I don't know about these days, but before the web browser Opera was based on Chromium, they had their own similar way to type Unicode: Ctrl+Shift+x, if I recall correctly, so that had to be used instead of Ctrl+Shift+u. If that's still true, this script won't work in Opera, of course. I don't have Opera so I haven't tried it. It works in Firefox, MousePad, LibreOffice, xfce4-terminal and probably in most of the Linux software out there.

I don't know if Autokey can detect which window you are working in, but if it can, the script could of course use this to implement whatever works in a given application.


Kind regards

Johnny Rosenberg

Little Girl

unread,
Aug 20, 2021, 12:49:41 AM8/20/21
to autoke...@googlegroups.com
Hey there,

If I'm understanding the original request, what's wanted is to use
the Compose (Super) key in combination with three dashes as an
Abbreviation for a phrase that would produce an em dash.

As far as I know, that's not currently possible. What you can do,
however, is any of these:
* use an Abbreviation
* use a hotkey by recording a keypress of one key
* use a hotkey two-key combination by recording a keypress of
one of the modifier keys (Control, Alt, Shift, Super,
Hyper, Meta) and any other key.

As an example, you could:

* Create a phrase with these contents: <ctrl>+<shift>+u+2014+

...or...

* Create a script with these contents:
keyboard.send_keys("<ctrl>+<shift>+u+2014+")

Then you could:

* Use a press of the Alt key and a press of the dash key as
its hotkey combination.

...or...

* Use --- as its Abbreviation (you may need to trick AutoKey
by saving it as x--- and then editing it afterwards to
remove the x) with these settings:
* Remove typed abbreviation
* Trigger when typed as part of a word
* Trigger immediately (don't require a trigger
character)

--
Little Girl

There is no spoon.

jos...@main.nc.us

unread,
Aug 21, 2021, 1:30:19 PM8/21/21
to autoke...@googlegroups.com


> Den sön 19 okt. 2014 kl 22:50 skrev Ineuw <in...@aei.ca>:
>
>> Google group forum post access is so strange from other forums. It took
>> awhile to get to this post. I know the compose key, which is in my case
>> the
>> left win key. I works fine to create symbols from non-numeric keystrokes
>> but not from Unicode numbers — This was created by Win + 3 hyphens in
>> quick
>> succession. It works in the latest Opera as well. But Lwin + 2014 or
>> Lwin +
>> u 2014 doesn't work.
>>
>
> Did you try to simulate the Ctrl+Shift+u method in Autokey? It seems to
> work for me, at least:
>
> # Types a — character.
> UniCode="2014"
> keyboard.send_keys("<ctrl>+<shift>+u")
Do you need a delay here? It seems weird.
> time.sleep(0.1)
> keyboard.send_keys(UniCode)
> keyboard.send_keys(" ")
>
>
> Result:
> —
>
> I don't know about these days, but before the web browser Opera was based
> on Chromium, they had their own similar way to type Unicode: Ctrl+Shift+x,
> if I recall correctly, so that had to be used instead of Ctrl+Shift+u. If
> that's still true, this script won't work in Opera, of course. I don't
> have
> Opera so I haven't tried it. It works in Firefox, MousePad, LibreOffice,
> xfce4-terminal and probably in most of the Linux software out there.
>
When Opera got sold after 12.x, a good chunk of the developer team left
and formed Vivaldi. If you liked Opera before it homogenized, you'll
probably like Vivaldi. It's the first browser I have liked since Firefox
3.x. It is the most configurable browser in the market and you can even
change a bunch of the look and feel if you know CSS. I'm a big fan for
over 4 years now. If you use a lot of browser tabs, nothing even comes
close to the way Vivaldi can manage them for you.
> I don't know if Autokey can detect which window you are working in, but if
> it can, the script could of course use this to implement whatever works in
> a given application.
That's exactly what Window filters are for. I use them regularly. I have
two print to file dialog helpers that are both triggered by Ctrl+P that
have different window filters - one for Mozilla apps and another for
Chromium apps.

Joe
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/CADo7T4eyr6NGU98Yhjs0HGaLs9Y_yE%3DiVt%2BytSfF3qPrCqVYMA%40mail.gmail.com.
>


Johnny Rosenberg

unread,
Aug 21, 2021, 1:42:58 PM8/21/21
to autoke...@googlegroups.com
I used Vivaldi for a while, but unfortunately it's also based on Chromium, so my personal keyboard layout doesn't work properly, it doesn't in any of the Chromium based web browsers that I tried so far. It works perfectly in Firefox though, that's why that's currently my only installed web browser.
I also loved the tab groups in former Opera and in Vivaldi, they are great, but I actually found a plug-in for Firefox that does the job quite OK. I'm sure there are several of those, but the one I use is called Simple Tab Groups. You can move tabs between groups, create new groups and everything like that, and it does it by just hiding those tabs that don't belong in the current group, which makes it fast. It takes some time to get used to when you are used to Vivaldi's approach, but now I find it very smooth.

Not saying everyone should skip Vivaldi and do this instead, I just mention this alternative.


Kind regards

Johnny Rosenberg
 

jos...@main.nc.us

unread,
Aug 21, 2021, 5:04:31 PM8/21/21
to autoke...@googlegroups.com
You can do that? That's a pretty good trick because I'm petty sure AutoKey
considers the dash as a word separator character.

Joe

> --
> Little Girl
>
> There is no spoon.
>
> --
> 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/611f3463.1c69fb81.9f3d3.ffcc%40mx.google.com.
>


Little Girl

unread,
Aug 21, 2021, 6:24:01 PM8/21/21
to autoke...@googlegroups.com
Hey there,

jos...@main.nc.us wrote:

>> Then you could:
>>
>> * Use a press of the Alt key and a press of the dash key as
>> its hotkey combination.
>>
>> ...or...
>>
>> * Use --- as its Abbreviation (you may need to trick
>> AutoKey by saving it as x--- and then editing it
>> afterwards to remove the x) with these settings:
>> * Remove typed abbreviation
>> * Trigger when typed as part of a word
>> * Trigger immediately (don't require a trigger
>> character)

>You can do that? That's a pretty good trick because I'm petty sure
>AutoKey considers the dash as a word separator character.

Yep. You can't start by saving it with just three dashes. The trick
is to save it with a letter at the start first and then edit it. I
actually set both the Alt+dash hotkey and the --- Abbreviation above
in AutoKey version 0.95.10 and they both work to trigger the script I
created to insert an em dash.

The only issue I foresee for the original poster would be if a dash,
a double-dash, and a triple-dash are all wanted as triggers.
Obviously, you wouldn't need AutoKey involvement to insert a single
dash, but there would be a conflict between an en-dash script that
triggers with -- and an em-dash script that triggers with --- with
the result being that you could never get an em dash because the en
dash would fire after the first two dashes. A work-around would be to
use something like -en and -em or -2 and -3 or -foo and -bar.

Then again, you could write it so that it's a dash dash space for the
en dash and a dash dash dash space for the em dash and then have the
Abbreviation remove the trigger and replace it with an en dash or an
em dash. I, personally, find that sort of thing disorienting, because
I know I just typed a space, but there isn't one, but that's easy
enough to get around by having the script insert a space after
the en dash or the em dash, which you'd probably want anyway when
using one. At any rate, that would fully get around the conflict
because the em dash wouldn't have a space after the second dash, so
each would fire separately.

Food for thought, anyway. I know it's not quite what the original
poster is used to, but perhaps something comfortable can be worked up.

Johnny Rosenberg

unread,
Aug 21, 2021, 7:24:28 PM8/21/21
to autoke...@googlegroups.com
Den lör 21 aug. 2021 kl 23:04 skrev <jos...@main.nc.us>:


> Hey there,
>
> If I'm understanding the original request, what's wanted is to use
> the Compose (Super) key in combination with three dashes as an
> Abbreviation for a phrase that would produce an em dash.
>
> As far as I know, that's not currently possible. What you can do,
> however, is any of these:
>       * use an Abbreviation
>       * use a hotkey by recording a keypress of one key
>       * use a hotkey two-key combination by recording a keypress of
>         one of the modifier keys (Control, Alt, Shift, Super,
>         Hyper, Meta) and any other key.
>
> As an example, you could:
>
>       * Create a phrase with these contents: <ctrl>+<shift>+u+2014+
>
>       ...or...
>
>       * Create a script with these contents:
>         keyboard.send_keys("<ctrl>+<shift>+u+2014+")

You can't have a + after the u. After pressing Ctrl+Shift+u, those key should be released.
You can do as I already suggested (and tested):
keyboard.send_keys("<ctrl>+<shift>+u")
keyboard.send_keys("2014 ")

The space has to be there.
>
> Then you could:
>
>       * Use a press of the Alt key and a press of the dash key as
>         its hotkey combination.
>
>       ...or...
>
>       * Use --- as its Abbreviation (you may need to trick AutoKey
>         by saving it as x--- and then editing it afterwards to

No, you can have --- as an abbreviation. I had no problems with that. The problem was for the OP, that --- meant something else in some software, so that was the problem with that, if I understood it correctly.
 
>         remove the x) with these settings:
>               * Remove typed abbreviation
>               * Trigger when typed as part of a word
>               * Trigger immediately (don't require a trigger
>                 character)
>
You can do that? That's a pretty good trick because I'm petty sure AutoKey
considers the dash as a word separator character.

The only problem I had with AutoKey in that matter was that it does not consider ”(” and ”)”  as separator characters, so you can't use abbreviations (without any tricks) right after a ”(”. The ”)” character is not a problem since they usually are followed by a space anyway according to writing rules.




Kind regards

Johnny Rosenberg

Joe

> --
> Little Girl
>
> There is no spoon.
>
> --
> 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/611f3463.1c69fb81.9f3d3.ffcc%40mx.google.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.

Little Girl

unread,
Aug 21, 2021, 11:39:34 PM8/21/21
to autoke...@googlegroups.com
Hey there,

Johnny Rosenberg wrote:
> Little Girl wrote:

>> > * Create a script with these contents:
>> > keyboard.send_keys("<ctrl>+<shift>+u+2014+")

>You can't have a + after the u. After pressing Ctrl+Shift+u, those
>key should be released.
>You can do as I already suggested (and tested):
>keyboard.send_keys("<ctrl>+<shift>+u")
>keyboard.send_keys("2014 ")
>
>The space has to be there.

Actually, you can use a space or a plus there. I find the space easy
to accidentally overlook, but if you like it, it's fine. I like the
plus, because you can see it, so you can quickly tell if your command
is complete or not.

The "Unicode Characters" page in the AutoKey wiki contains everything
I've discovered and/or have been told by others so far about what
AutoKey expects and/or requires when it comes to Unicode characters:

https://github.com/autokey/autokey/wiki/Unicode-Characters

Please feel welcome to contribute to that page.

>> > * Use --- as its Abbreviation (you may need to trick
>> > AutoKey by saving it as x--- and then editing it afterwards to

>No, you can have --- as an abbreviation. I had no problems with
>that.

Interesting. Which version of AutoKey are you using and in which
environment? When I use AutoKey version 0.95.10 under Kubuntu 20.04
LTS inside of a VirtualBox virtual machine, I have to "trick" AutoKey
to get it to accept --- as an Abbreviation in both the Qt and GTK
versions of AutoKey. Once the Abbreviation is properly in place,
though, both versions of AutoKey accept it.

You've made me curious, so I loaded up my trusty old AutoKey version
0.90.4 and tried it. It accepted --- as an abbreviation without a
fight. Something changed in that part of the code between those two
versions. I'll mention it in the Gitter chat and see if this is
considered a bug, intentional, interesting, neutral, or something
else.

>The problem was for the OP, that --- meant something else in some
>software, so that was the problem with that, if I understood it
>correctly.

Yep. My example was just one possible way to do a hotkey combination
and one possible way to do an Abbreviation. The original poster can
customize those in any number of ways, hopefully to find a
comfortable one.

Shmu26

unread,
Nov 11, 2022, 2:18:00 AM11/11/22
to autokey-users
"Or just create a phrase and enter an m-dash (–—) there."
This didn't work for me before, but it now worked on version 0.96.0
Awesome.

Reply all
Reply to author
Forward
0 new messages