2
votes

In Onenote, let's say I want to write x^y (x to power of y), I would need to enter Equ mode (by keyboard shortcut) , type x^y , hit Space, then exit equ mode

So, I figure it could be something like this :

::(wild_card)^(wild_card)::  
Send, (Shortcut for equ mode)  
Send, variable1  
Send, ^
Send, variable2  
Send, space  
Send, (Shortcut for equ mode)  

How do I actually achieve this ?

Alternatively, the same purpose could be formulated by doing,
- monitor word separated by Ending chars
- detect if ^ is in those word
- Send (Shortcut) , then the word, then space, then (Shortcut).
Is this more doable ?

1
Have a look at RegEx Powered Dynamic Hotstrings. You'll need to do just a few adjustments to the percent example to get what you want. Of course, you should check if OneNote is active before triggering. - MCL

1 Answers

2
votes

Thanks MCL,

Here is the code for auto convert x_y and x^y into their mathematical representation in onenote

#Include DynamicHotstrings.ahk
#IfWinActive, ahk_class Framework::CFrame
hotstrings("(\w+\_\w+) ","dowork")
hotstrings("(\w+\^\w+) ","dowork")

dowork:
    Send, {LAlt Down}{=}{LAlt Up}
    SendRaw, %$1%
    Send,  {Space}
    Send, {LAlt Down}{=}{LAlt Up}
    Send,  {Space}
    Return

Better yet , you can modify the DynamicHotstrings.ahk so it will ignore auto convert when we are already in equation mode:

hotstrings(k, a = "")
{
    CoordMode,Pixel,Screen
    PixelGetColor, color, 455, 1
    if (color =  0xD7337F)
        return
      ....