CaretGetPos

Retrieves the current position of the caret (text insertion point).

CaretGetPos(OutputVarX, OutputVarY)

Parameters

OutputVarX/Y

The names of the variables in which to store the X and Y coordinates. The retrieved coordinates are relative to the active window's client area unless overridden by using CoordMode or A_CoordModeCaret.

Remarks

If there is no active window or the caret position cannot be determined, the function returns false and the output variables are made blank. The function returns true if the system returned a caret position, but this does not necessarily mean a caret is visible.

Any of the output variables may be omitted if the corresponding information is not needed.

Note that some windows (e.g. certain versions of MS Word) report the same caret position regardless of its actual position.

Related

CoordMode, A_CoordModeCaret

Example

SetTimer "WatchCaret", 100
WatchCaret() {
    if CaretGetPos(x, y)
        ToolTip "X" x " Y" y, x, y - 20
    else
        ToolTip "No caret"
}