I use lots of subscripts and scripts. For example H₂O, Ca⁺², X², CaH₍₂₋ₓ₎ etc. I can make numeric and some symbols as subscripts and superscripts using unicode similar to the following code but I have found no way to capture the + symbol to generate the + superscript. How can I capture the + keystroke as I type to generate the unicode ⁺?
<!2:: ; left alt + 2 creates 2 subscript
send ₂
<!(:: ; left alt + ( creates ( subscript
send ₍
return
return
>!2:: right alt + 2 creates 2 superscript
send ²
return
How can I use the + keystroke in a hotkey?
-
- Posts: 4
- Joined: 24 Apr 2019, 16:43
Re: How can I use the + keystroke in a hotkey?
I'm not entirely certain of what you're doing, but I imagine that using the VK code of the key would solve your problem. The VK code for the + key is vkBB. You can make a hotkey for it by doing vkBB:: or, if you're reading input, you may need to use the GetKeyVK() function to know when it's encountered.
The TooltipKeypress script is very helpful for discovering key codes by running it or just looking at the scripting to see how to do a handle input:
The TooltipKeypress script is very helpful for discovering key codes by running it or just looking at the scripting to see how to do a handle input:
Code: Select all
CoordMode, ToolTip, Screen
SetFormat, IntegerFast, H
CleanTimer := -3000 ; Must be a negative number (the timer will run only once)
Loop, 5000
{
Hotkey, % "~*" GetKeyName(Format("vk{:x}", a_index - 1)), GetText
Hotkey, % "~*" GetKeyName(Format("sc{:x}", a_index - 1)), GetText
}
; "~" keeps the button original function
; "*" fires the hotkey even if extra modifiers are being held down
Gui, New, -MinimizeBox
Gui, Add, Edit, w200 h100,
Gui, Show
Return
GetText:
SetTimer, CleanText, Off
Sleep, 50
Key := RegExReplace(A_ThisHotkey, "^..") ; "^.." removes the first 2 characters ("~*") from the returned string
KeyVK := GetKeyVK(Key)
KeyVK := RegExReplace(KeyVK, "^..")
KeySC := GetKeySC(Key)
KeySC := RegExReplace(KeySC, "^..")
Text .= Key
ToolTip, % "Key Name: {" Key "}`nKey VK: {vk" KeyVK "}`nKey SC: {sc" KeySC "}`n`n" Text, 0, 0 ; X\Y coordinates
SetTimer, CleanText, %CleanTimer%
Return
CleanText:
Text := ""
ToolTip
Return
GuiClose:
ExitApp
Return
Who is online
Users browsing this forum: Google [Bot] and 138 guests