How to set text cursor at coordinate?

D.D.K-2637 966 Reputation points
2023-01-22T23:34:18.7466667+00:00

Hi,

Let's say I have text strings as shown. how do I move cursor to the specify characters?

The boxes can be controls in an application example mfc, chrome,...

User's image

User's image

I tried using SetConsoleCursorPosition but the result always returns 0, is that the right approach?

Thanks you.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,712 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,830 questions
{count} votes

Accepted answer
  1. Castorix31 86,496 Reputation points
    2023-01-23T09:33:19.6066667+00:00

    It can be done with IUIAutomation and MoveEndpointByUnit

    Test with Edit control of Notepad, position 10 :

    MoveEndpointByUnit


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.