Finding current location

I am trying to get the current location of where the curser is located. Are there any commands for this currently without using an image or text. Just need the 2 coordinates. This is after using the tabkey to go to a different section and need to location coordinates to read the text. Any help is appreciated,

log MouseLocation() //Logs the current location of the mouse cursor

That’ll get you your mouse location, but I don’t think that’s going to help. I’m not sure the location of the mouse will even be where the keyboard focus is.

I think you will probably need to find some other reference point from which to draw your readtext rectangle.

Good luck!

Hi Greg,
is the SUT a Web App? In this case the cursor position is more the position of the active web element, what possibly can be catched with the Webdriver and/or a javascript. I had in the past a similar problem, but could not use the Webdriver.
But to check correct positioning with tabKey into writable textfields it was possible to use the command sequence
typetext “dummyTextNowhereInUse”
if ImageFound(text:“dummyTextNowhereInUse”,SearchRectangle:…) then
DoubleClick FoundImageLocation()
typetext deleteKey
…
else
…
Maybe this could be a possible solution for you as well.
BR

1 Like

I think @GammaG 's solution is inventive, but whether it will work for you depends on the degree of precision you need for the cursor location. If you think about it, the cursor position could be defined by a pair of coordinates representing the top and bottom of the cursor. If you only wanted one pair, would that correspond to the bottom of the cursor or the center of the cursor? Here is a slight modification of the code:
TypeText “mynonsensetext”,Tab
set myTextPosition to ImageRectangle(text:“mynonsensetext”, waitFor:1)
Log “The rectangle that binds my text is:”&&myTextPosition
set varTopOfCursor to [item 1 of myTextPosition,item 2 of myTextPosition]
Log “The top of my cursor is:”&&varTopOfCursor
set varBottomOfCursor to [item 1 of myTextPosition,item 4 of myTextPosition]
Log “The bottom of my cursor is”&&varBottomOfCursor
Click FoundImageLocation()
TypeText controlKey,“a”
TypeText deleteKey