Any way to change the fontsize shortcut in Microsoft OneNote

microsoft-onenote

I have been using Microsoft OneNote for months and using it as it should have to be used. When I started to use OneNote, whenever I needed to increase or decrease font-size, I tried to apply the common MS Word shortcut, but it didn't work for me.

After months, it came to my knowledge that it's possible to increase or decrease font-size using Ctrl + Shift + > or Ctrl + Shift + <. But I don't like these shortcuts.

Is there any way to customize the OneNote keyboard shorcuts?

Best Answer

Using AutoHotkey:

#if WinActive("ahk_exe ONENOTE.EXE")
^NumpadAdd::^+.
^NumpadSub::^+,
#if

If you don't want to use + and - keys on a numerical keyboard replace NumpadAdd with = and NumpadSub with - (assuming you have an EN keyboard layout and want to use the keys next to backspace).

The ^ stands for Ctrl, + for Shift and ! would stand for Alt if you want to modify the hotkeys (more info on special modifiers).


Complex explanation

I'm a bit of an AutoHotkey nerd, because I encounter these types of issues often in my own workflow and couldn't help myself not to explain how the language works here. In case anybody wants to delve into the deep waters, here you go:

The < > and + key problem:

For me the < and > keys normally act (without the Shift and Control) as a dot . and comma , and + acts as =, and that is also the proper way to write them into the script. Another possible reason for why a version of the script with these keys wouldn't trigger is because the <, > and + are special modifier symbols. In case normal key names don't work at all, there are also special virtual key IDs {vk##} and scan codes {sc##} which can be used instead and figured out using KeyHistory. There is a bit more complexity and preparation to this last part, example here.

The window detection:

Additionally a better way to approach the window title in WinActive in this case may be to refer to the .exe directly using ahk_exe [app_name_goes_here].exe. Name of the OneNote executable may differ in other editions (I'm using OneNote 2016). You can figure it out using WindowSpy.ahk (which is an app that should be a part of every AutoHotkey installation (you will find it in the AutoHotkey folder)) or by looking for the OneNote executable in the task manager.

Proper use of WinActive in this case:

In order to not disrupt the new hotkey combination (^NumpadAdd + ^NumpadSub) added using the script in other apps it's important to make them context-sensitive using #If, which has to be positioned above these hotkey declarations. If you want to expand the script with non-context-sensitive code underneath, it's important to turn the context-sensitivity off using an empty #If statement.

One-line hotkeys and no need for Send/SendInput:

If the hotkey is simple enough that it fits into one line, it doesn't need to return and doesn't even need to use Send or SendInput. This can however prove tricky if you need to use specially named keys such as NumpadAdd which would in Send be written with {} around them. (example Send {NumpadAdd})

Related Question