Get X/Y position of caret (input text cursor) under Xorg? Get X/Y position of caret (input text cursor) under Xorg? linux linux

Get X/Y position of caret (input text cursor) under Xorg?


So, after doing some research I was able to figure out one way to implement this:

  • use xdotool to paste some random string
  • use OCR to find coordinates of the random string
  • use xdotool to remove random string

The problem is that this approach is pretty slow (up to 10 seconds depending on how much text there is on the screen).

I'v also tried comparing screenshots (before/after inserting text) and it's much faster, but a lot less precise.