Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coordinates of selected text
#1
Hi Gintaras and QMers.

Please, any idea on how to get the absolute coordinates of a selected text, for example in any doc or web page? In a notepad, I was trying some code as indicated below.

Thanks for any help.

Macro Macro1473
Code:
Copy      Help
int hWndEdit=id(15 win("Untitled - Notepad"))

int selStart selEnd

SendMessage(hWndEdit, EM_GETSEL, &selStart, &selEnd)

int i = SendMessage(hWndEdit, EM_POSFROMCHAR, selStart, 0)

int x=i & 0xFFFF
int y=i >> 16

out F"x:{x} y:{y}"
#2
x y coordinates, or character position?
To get x y, maybe scan (find image or color) can be used. Or GetCaretXY.
To get character position, it is possible only in Edit controls and in few other controls.
#3
x y coordinates, please.

With string.getsel I get the text, but I would need the x,y coordinates.
Scan is not reliable with different colors and GetCaret is for editable texts, not for any webpage or document.
#4
Macro Macro2553
Code:
Copy      Help
int w=win("Untitled - Notepad" "Notepad")
;int w=win("Mozilla Firefox" "MozillaWindowClass")

act w
scan F"color:{GetSysColor(COLOR_HIGHLIGHT)}" w 0 3|16
err OnScreenDisplay "no selection"
#5
What a very nice and smart solution! I spent hours dealing with winapis with zero success.

Thanks for your help. Best regards.


Forum Jump:


Users browsing this thread: 1 Guest(s)