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.
But to check correct positioning with tabKey into writable textfields it was possible to use the command sequence
if ImageFound(text:“dummyTextNowhereInUse”,SearchRectangle:…) then
Maybe this could be a possible solution for you as well.
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:
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