Posts: 135
Threads: 33
Joined: Aug 2009
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
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}"
Posts: 12,072
Threads: 140
Joined: Dec 2002
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.
Posts: 135
Threads: 33
Joined: Aug 2009
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.
Posts: 12,072
Threads: 140
Joined: Dec 2002
Macro
Macro2553
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"
Posts: 135
Threads: 33
Joined: Aug 2009
What a very nice and smart solution! I spent hours dealing with winapis with zero success.
Thanks for your help. Best regards.