Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cursor Location
#1
Hi,
I know how to get the mouseposition but say I want to do something at the blinking cursor location within a window. How do I get that position (not neccessarily the pixel location but the focus of where to return to for addition paste/inserts, etc)
Thanks,
Stuart
#2
GetCaretXY.
#3
Is there a way to detect when this same blinking [insertion point cursor] EXISTS, rather than actually finding the location? With GetCaretXY I get [0,0] with no blinking cursor and in some windows I get [0,0] when the cursor actually does exist - [0,0] may be relative to the window but it doesn't help me when [0,0] is the return value even when the cursor does not exist. I just need to know if the user has left clicked inside an editable window, leaving a blinking cursor. I need to reliably detect qualitatively the blinking cursor, not find its location. Is this possible?

Thanks,
Brad
#4
GetCaretXY returns handle of window with caret, or 0 if caret is hidden.
But not in all windows/controls is works. I don't know other ways.
#5
Function IsEditableTextControlFocused
Code:
Copy      Help
;/
function# [&caretX] [&caretY] [&caretW] [&caretH] [Acc&aFocus]

;If caret is in an editable text field, returns handle of the control.
;Else returns 0.
;This function works not with all windows/controls.

;caretX ... - optional variables that receive caret location and focused accessible object.


int x y cx cy
int w=GetCaretXY(x y cx cy)
if(!w) ret

Acc a=acc
if(!a.a or a.State&STATE_SYSTEM_READONLY) ret

if(&caretX) caretX=x
if(&caretY) caretY=y
if(&caretW) caretW=cx
if(&caretH) caretH=cy
if(&aFocus) aFocus=a

ret w

test
Macro Macro1500
Trigger F12     Help - how to add the trigger to the macro
Code:
Copy      Help
out
int w1 x y cx cy; Acc a
w1=IsEditableTextControlFocused(x y cx cy a)
if(!w1) ret
out "%i %i %i %i" x y cx cy
outw w1
a.Role(_s); out _s
a.State(_s); out _s
out a.Name
out a.Value

Tested with simple edit/richedit controls, IE, Firefox and Word 2003.
#6
Thank you. This function works well in Compatible windows/controls. I see that GetCaretXY cannot always return all window/control handles, but I am trying to detect when the caret exists at all. I don't necessarily need the handle. I am trying to detect the caret similar to searching the screen for the "caret" image (like using the "Find Image" method of locating a bitmap on the screen). But, I wanted a more efficient method of quickly detecting the blinking caret on the screen. Is there such a way to detect the blinking caret in all windows other than using the search for image method?
#7
I don't know other ways.
Some windows use standard caret, others draw caret like an image, and provide accessibility info for it, others don't provide info, and then all we can do is to get pixels from screen, like scan does.
#8
Thank you for all your help

Brad


Forum Jump:


Users browsing this thread: 1 Guest(s)