0

Figure 1

As shown in Figure 1, I have got the global mouse cursor coordinates and loaded an NSWindow next to it. (Upper right corner of the picture)

Next, I will load this NSWindow to the right of the text input cursor, so that it follows the input cursor instead of the mouse cursor. (Bottom left corner of the picture)

Can I get the coordinates of the input cursor? It is best to be relative to the coordinates of the entire screen.

Thank you for your time!

  • That's not a good plot. – El Tomato May 11 '21 at 10:50
  • Is the insertion point in a window of your app? – Willeke May 11 '21 at 10:59
  • @Willeke No, the insertion point can be any input box. It can be the edit box of the mail, the chat box of the App and the word file. – Appleseed Jian May 11 '21 at 14:11
  • Does this answer your question? [Get Current Keyboard Cursor Location](https://stackoverflow.com/questions/19432454/get-current-keyboard-cursor-location) – Willeke May 11 '21 at 14:18
  • See also [How to get global screen coordinates of currently selected text via Accessibility APIs.](https://stackoverflow.com/questions/6544311/how-to-get-global-screen-coordinates-of-currently-selected-text-via-accessibilit) – Willeke May 11 '21 at 14:18
  • @Willeke Yes, this provides me with a new search direction. I need some time to check it out. Thanks again for your reply. – Appleseed Jian May 11 '21 at 14:34
  • @Willeke Thank you for your reply. The question of getting the keyboard cursor is my question. The first answer I didn't understand, and the second answer mentioned that this requirement could not be fulfilled. In addition, getting the coordinates of the currently selected text through the accessibility API does not seem to meet my needs, because I did not select the text. – Appleseed Jian May 11 '21 at 14:57
  • The answer to both questions is to get `kAXSelectedTextRangeAttribute`. – Willeke May 11 '21 at 15:28

0 Answers0