Hotkey for formulae with superscript

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
rnocked01
Posts: 1
Joined: 22 Feb 2018, 13:51

Hotkey for formulae with superscript

22 Feb 2018, 14:03

I am a complete newbie, to coding in general.
I want to set up just a few hotkeys for chemical formula I use regularly, that include superscript or subscript and special characters. Since notepad and notepad++ don't have an obvious way to write it.
For example, I want to set Alt+C to insert d13C where d is actually a small case greek delta and the 13 is in superscript. I know how to get to charmap to specify the delta, but I can't for the life of me figure out how to get the 13 in superscript. I am sure there must be a way to tell autohotkey using the unicodes for each character including superscript and subscript numbers, I just don't know enough to do it.
Thanks
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Hotkey for formulae with superscript

22 Feb 2018, 16:03

I only know of Superscript 1, 2, and 3 -- ¹, ², and ³. I don't know of them for 4-9; and technically not 0, although ° as 0 kind of works. I don't know that Notepad++ supports a superscript like Microsoft Word as a text editor does, or the superscript HTML tags for websites, but you would want to be able to use the native hotkeys in the application or clicking on a button in the toolbar to toggle in and out of super script.

This is the code I use for ¹, ², and ³.

Code: Select all

3::Send {U+00B3} ; ASC 254 I think is alternative
2::Send {U+00B2} ; ASC 253 I think is alternative
1::Send {U+00B9}
In case it matters, I run the unicode version of AHK.

Also, for creating the δ character, I use this:

Code: Select all

d::Send {U+03B4} ; delta
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Hotkey for formulae with superscript

22 Feb 2018, 20:04

- There are two classic ways of doing superscript/subscript: text formatting (that you lose when you paste into Notepad), and hardcoded Unicode characters. I'm not sure how you would do this in Notepad++.
- Btw sometimes I've wanted to do superscript and subscript numbers one on top of the other, but I haven't found a good way to do this, other than formula boxes in MS Word, or using LaTeX, but not in ordinary plaintext in Notepad, or formatted text in WordPad.

Code: Select all

q:: ;ms word - 1, subscript 2, 3
;subscript via text formatting
Send, 1^=2^=3
return

w:: ;ms word - 1, superscript 2, 3
;subscript via text formatting
Send, 1^+=2^+=3
return

e:: ;anywhere - 1, subscript 2, 3
;subscript via hardcoded Unicode characters
;⁰¹²³⁴⁵⁶⁷⁸⁹ ₀₁₂₃₄₅₆₇₈₉
Send, 1₂3
return

r:: ;anywhere - 1, superscript 2, 3
;subscript via hardcoded Unicode characters
;⁰¹²³⁴⁵⁶⁷⁸⁹ ₀₁₂₃₄₅₆₇₈₉
Send, 1²3
return

t:: ;character to number
vChar := "²"
;vChar := Chr(178)
;vChar := Chr(0xB2)
MsgBox, % vChar "`r`n" Ord(vChar) "`r`n" Format("0x{:X}", Ord(vChar))
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Holarctic, jameswrightesq and 446 guests