Search code examples
pythonpywin32

Is it possible to get the current insertion point (text cursor / caret) of the active window in python?


Not sure if this is even possible - but for a small text utility I'm writing I need to know the x/y coordinates of the insertion point/caret/text cursor in the current active window on a MS Windows system. Is this doable with something like pyWin32 or is it just impossible?


Solution

  • It is doable I believe. It would be in the win32gui module. The call for this is something like win32gui.GetCaretPos()

    Here's the (terrible) documentation for it: http://timgolden.me.uk/pywin32-docs/win32gui.html