Sending em and en dashes easily and quickly Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Rok
Posts: 63
Joined: 11 Jan 2016, 08:50

Sending em and en dashes easily and quickly

Post by Rok » 30 Nov 2023, 09:46

::--::— was working just fine for me by itself to send an em dash in any application by typing two consecutive hyphens or minus signs, just like this works in Microsoft Word and Telegram without the intervention of an AHK script, which is also why I have the code looking like this:

Code: Select all

#HotIf !WinActive("ahk_exe Telegram.exe")
::--::—
::---::– 	; This is the addition that doesn't quite work due to two consecutive minus signs sending the em dash before an en dash can be sent.
#HotIf
However, now I also need to quickly type an en dash . The immediate idea that came to me was to send it by typing 3 consecutive minus signs. As expected, this clashes with sending an em dash with 2 consecutive minus signs, as an em dash is immediately sent after typing 2 consecutive minus signs before an en dash can be sent by typing three of them.

Alternatively, I could also send two minus signs for an em dash and hold down the minus-sign key for a bit longer than normal to send an en dash. I tried to write the code for this one but failed.

I'm looking for a solution to this problem, or an even better idea than typing 3 consecutive minus signs or holding down minus to send an en dash.

Thanks for any help and tips on this issue.
Last edited by Rok on 30 Nov 2023, 10:31, edited 3 times in total.

User avatar
mikeyww
Posts: 27162
Joined: 09 Sep 2014, 18:38

Re: Sending em and en dashes via multiple minus signs  Topic is solved

Post by mikeyww » 30 Nov 2023, 10:11

Code: Select all

:C:md::—
:C:nd::–

Rok
Posts: 63
Joined: 11 Jan 2016, 08:50

Re: Sending em and en dashes via multiple minus signs

Post by Rok » 30 Nov 2023, 10:29

mikeyww wrote:
30 Nov 2023, 10:11

Code: Select all

:C:md::—
:C:nd::–
Not what I had in mind — serendipitous in my case this time, but concise and elegant — creatively genius — as usual, mikeyww. :salute:

Thank you! :D

For any AHK beginners who stumble upon this, here's the code with potentially helpful comments:

Code: Select all

:C:md::— 	; The ":C:" prefix before the "md" key combination signifies that the replacement is case-sensitive, so if you type "MD" in uppercase letters, that will not send an em dash. Otherwise, type "md" to send an em dash.
:C:nd::– 	; If you type "ND" in uppercase letters, that will not send an en dash. Otherwise, type "nd" to send an en dash.

Post Reply

Return to “Ask for Help (v2)”