David H. J.
David H. J.

Reputation: 412

How to get the caret position in OneNote 2016 using AutoHotkey?

I want to move the mouse cursor to the position of the caret. There's a built-in variable A_CaretX and A_caretY for getting the position of caret. So, I wrote something like this:

mousemove,% A_CaretX, A_CaretY

This works in Microsoft Word, but not in OneNote 2016.

Am I doing something wrong, or does it incompatible with the app? If so, is there any workaround?

I'm using Autohotkey 1.1.30.03.

Upvotes: 0

Views: 208

Answers (2)

Wittybrit
Wittybrit

Reputation: 11

For what it's worth (3 years later). It took me using this AHK v2 code to realize that OneNote (Win11, Office 365) doesn't record the position of the caret.

WatchCaret() { if CaretGetPos(&x, &y) ToolTip "X" x " Y" y, x, y - 20 else ToolTip "No caret" }

Upvotes: 1

Sebastian Helm
Sebastian Helm

Reputation: 1

If all else fails, you can use ImageSearch to retrieve the position of a part of the caret that sticks out, in other words is far away enough from adjacent characters to be recognizable.

Upvotes: -1

Related Questions