jakkaas
jakkaas

Reputation: 1

How to make AutoHotkey script for selecting a pen in OneNote(UWP)?

To give you an intro, I am not a programmer but a biologist who is learning a bit of programming.

Now I use OneNote a lot and continuously switch between typing and touch-based inking.

Now OneNote UWP does not have a shortcut for selecting a pen.

But I found out that by pressing Alt+d and then down and then continuously pressing right six times and then pressing enter, one can switch to pen via keyboard.

Now I want to automate the above process and link it to Numpad 1.

So I tried AutoHotkey and tried to learn making a script of the above command but still no success.

This is what I tried (3-4 different ways):

Numpad1::
!d
Down
Right
Right
Right
Right
Right
Right
Right
Enter

I know this script is wrong but I can't find the correct way to do it.

Upvotes: 0

Views: 263

Answers (1)

user10364927
user10364927

Reputation:

You're off to a good start! In order to send the keystrokes, you'll need to use one of the variations of the Send command. In addition, we can also make it so that it only work when OneNote is the active window using the #If directive. (It makes hotkeys context-sensitive.)

I don't have OneNote on my machine, but please verify that the title contains "OneNote" for the following script to work.

SetTitleMatchMode , 2
#If WinActive("OneNote")
Numpad1::Send , !d{down}{right 6}{enter}
#If


Edit: I installed OneNote to try it out. It appears to run too quickly. I added a key delay of 75ms and changed Send to SendEvent, which obeys the key delay. This worked fine for me:

SetTitleMatchMode , 2
SetKeyDelay , 75
#If WinActive("OneNote")
Numpad1::SendEvent , !d{down}{right 6}{enter}
#If

Upvotes: 1

Related Questions