How input methods get the keyboard caret/cursor position? And how to do that in C#? RRS feed

  • Question

  • I am working on a C# project, which need to get the keyboard caret/ cursor position.

    The method I am using is by calling Win32 Apis. By using this blog:

    gUITHREADINFO.cbSize = (uint)Marshal.SizeOf(gUITHREADINFO);

    if (!NativeMethods.GetGUIThreadInfo(0, out gUITHREADINFO))
       return new int[] { 0, 0 };
    public static extern bool GetGUIThreadInfo(uint tId, out GUITHREADINFO threadInfo);

    But such method has limitations. It won't work in Chrome and Chrome based applications, nor it works in Java based applications.

    I noticed that some Non-English input method has a feature to keep track of keyboard input cursor/caret. How they do the job? Or how I can get the keyboard caret in Chrome in C#?

    Monday, June 10, 2019 9:51 PM


  • Hello singer-neu,

    This forum is for "Discuss general issues about developing applications for Windows."

    Since this issue is C# related I'll move it to C# forum for more professional support.

    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    • Marked as answer by singer-neu Tuesday, June 11, 2019 9:18 PM
    Tuesday, June 11, 2019 3:09 AM