Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get position of cursor
#1
I think that I use to have this but I can not find it. Is there a way to get the cursor or I beam position, in notepad, relative to 0,0 of id 15?
#2
int hwnd=id(15 win("Notepad" "Notepad"))
lef 0 0 hwnd
#3
This just makes the mouse hover over 0,0 of id 15.I need to know that Notepads I beam is at (the forth space of row 2) relative to 0,0 of id 15 of Notepad.
   
#4
Function GetCaretXY gets text cursor position, where possible.
#5
Yes that works however, that is always relative to the screen 0,0 and not relative to 0,0 of id 15 of Notepad.

Macro
Code:
Copy      Help
int CaretX CaretY
GetCaretXY CaretX CaretY
out CaretX
out CaretY
#6
GetCaretXY CaretX CaretY 0 0 1
will be relative to the client area of the child window where caret is.
#7
Thank you – One question. Where is the documentation on the flags or should I just try flags on all functions?
#8
Only what you see in status bar or when press F1.
#9
Hi!
I use the below function many times.

int x y
int h=GetCaretXY(x y)

to get caret coordinates in "Microsoft word 2003 on my windows XP"
The (h,x, y) are alway (0, 0, 0). Sad
It is relative to screen and works for Notepad, however.

I search on the internet for a long time
The problem seems that after GetGUIThreadInfo
the g.hwndCaret =0, g.rcCaret.left .... are not exist.
Can QM experts help me, please!
#10
Macro Macro1408
Trigger F12     Help - how to add the trigger to the macro
Code:
Copy      Help
act win("Microsoft Word" "OpusApp")
1.5 ;;wait 1.5 s because Word does not give caret pos for 1 s after window activation

int x y h
h=GetCaretXY(x y 0 0 1) ;;the 1 makes the returned pos relative to the client area of h
if(!h) mes- "Failed."
out "%i %i" x y


Forum Jump:


Users browsing this thread: 1 Guest(s)