Subscripts

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
diegg1739
Posts: 103
Joined: 17 Oct 2023, 18:29

Subscripts

11 May 2024, 09:26

Hello. With the help of forum users, I have an AHK V.2 script to insert subscripts in the Paint.net app and Edge browser.

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance

char := Map(
  'a', 'ₐ'
 , 'e', 'ₑ'
 , 'h', 'ₕ'
 , 'i', 'ᵢ'
 , 'j', 'ⱼ'
 , 'k', 'ₖ'
 , 'l', 'ₗ'
 , 'm', 'ₘ'
 , 'n', 'ₙ'
 , 'o', 'ₒ'
 , 'p', 'ₚ'
 , 'r', 'ᵣ'
 , 's', 'ₛ'
 , 't', 'ₜ'
 , 'u', 'ᵤ'
 , 'v', 'ᵥ'
 , 'x', 'ₓ'

)
ih := InputHook(), ih.KeyOpt('{All}', 'E')

#HotIf WinActive('ahk_exe paintdotnet.exe') or WinActive('ahk_exe msedge.exe')
LAlt::ih.Start(), ih.Wait(), char.Has(ih.EndKey) && Send(char[ih.EndKey])
#HotIf
The problem is that not all letters are as subscripts in Windows 10's "Character Map", where I extracted the subscripts from. For example, b, c, d, among others, are not there. They do not have Unicode encoding. Is there a way to insert these characters using an AHK script? Thank you so much.
Rohwedder
Posts: 7719
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Subscripts

11 May 2024, 10:56

Hallo,
try:

Code: Select all


#Requires AutoHotkey v2.0
#SingleInstance

char := Map(
 'a', Chr(8336)
 , 'e', Chr(8337)
 , 'h', Chr(8341)
 , 'i', Chr(7522)
 , 'j', Chr(11388)
 , 'k', Chr(8342)
 , 'l', Chr(8343)
 , 'm', Chr(8344)
 , 'n', Chr(8345)
 , 'o', Chr(8338)
 , 'p', Chr(8346)
 , 'r', Chr(7523)
 , 's', Chr(8347)
 , 't', Chr(8348)
 , 'u', Chr(7524)
 , 'v', Chr(7525)
 , 'x', Chr(8339)

)
ih := InputHook(), ih.KeyOpt('{All}', 'E')

#HotIf WinActive('ahk_exe paintdotnet.exe') or WinActive('ahk_exe msedge.exe')
LAlt::ih.Start(), ih.Wait(), char.Has(ih.EndKey) && Send(char[ih.EndKey])
#HotIf
User avatar
Seven0528
Posts: 394
Joined: 23 Jan 2023, 04:52
Location: South Korea
Contact:

Re: Subscripts

11 May 2024, 11:01

 You can't do it. Simply because it's not defined in Unicode.
It's not something that was accidentally omitted in Word, it simply doesn't exist from the beginning.

From a brief search, it seems that even individual characters were not added at the same time, but gradually over time.
The fragmented nature of Unicode ranges can be considered indirect evidence of that.
Whether it will be added to Unicode in the future is uncertain, but currently, it's not possible.
  • English is not my native language. Please forgive any awkward expressions.
  • 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.
diegg1739
Posts: 103
Joined: 17 Oct 2023, 18:29

Re: Subscripts

11 May 2024, 11:18

Thank you very much Rohwedder. Indeed, those subscripts that are in your script are the ones that I can use, but I can't get subscripts for the letters b, c, d, f, g, q, y, z.
diegg1739
Posts: 103
Joined: 17 Oct 2023, 18:29

Re: Subscripts

11 May 2024, 11:20

Thank you for your comment seven0528. I was afraid something like this would happen. Hopefully Unicode completes the list of subscripts, which are often used frequently. I do not know what the technical difficulties or limitations would be why they were not coded from the beginning.
User avatar
Seven0528
Posts: 394
Joined: 23 Jan 2023, 04:52
Location: South Korea
Contact:

Re: Subscripts

11 May 2024, 11:38

 Unicode request for Latin subscript letters
This is part of the document I was able to find on the Unicode official website.
Honestly, since English is not my native language, I didn't really want to read it, but it might be helpful.
These characters seem to have been added with very specific purposes.

This is just my personal opinion, but I have looked through all the Unicode character charts before.
Among them, there were cases where only some Latin characters were added for specific purposes (such as mathematical purposes),
but later on, all Latin characters were added.
There were also cases where newly added characters were assigned to separate areas,
and cases where all characters were assigned to separate areas. (In these rare instances, duplicate characters with the same shape occurred.)

It might be added later as you wish, but it's not definitive because the Unicode space is finite.
Even if characters are added, it will take quite some time for fonts to support them.
Who knows, I'm not even the person in charge. Haha...
  • English is not my native language. Please forgive any awkward expressions.
  • 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.
User avatar
boiler
Posts: 17206
Joined: 21 Dec 2014, 02:44

Re: Subscripts

11 May 2024, 11:47

Yes, unless a proposal is submitted that makes the specific case as to why certain subscript characters are need for cases like mathematical or chemical equations, they won’t be eventually added just because they are “missing.” You say they are used frequently. Somewhat would have to submit a proposal to the Unicode Consortium making the case for the specific reason they are used frequently and should be added. Apparently no one has yet offered a compelling argument, if any at all.
diegg1739
Posts: 103
Joined: 17 Oct 2023, 18:29

Re: Subscripts

11 May 2024, 12:52

Very interesting, seven0528, that request to Unicode to add the missing subscript characters. Thank you very much for your search and collaboration.
diegg1739
Posts: 103
Joined: 17 Oct 2023, 18:29

Re: Subscripts

11 May 2024, 13:10

Right, boiler. There is the proposal that seven0528 reported in the link in his comment. I hope it is taken into account. Thank you so much.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: Descolada, Draken and 25 guests