Click mouse

Is there a way to click the mouse left button at the curser's current location? Then I want to repeat the clicking three times to automate highlighting a paragraph. Trying to imitate Brett Terpstra's key bindings using Keyboard Maestro.

image

Thank you, I feel stupid now.

Don't let it bother you. A wise person once said "everyone is my superior in some respect." And by that I mean you are our superior so we respect you.

1 Like

I am wondering if it is possible to do the same in the caret insertion point.

I can perform a right click in the insertion/caret position rather easily.

tell application "System Events" to set frontApp to name of first process whose frontmost is true

tell application "System Events"
	tell application process frontApp
		set _selection to value of attribute "AXFocusedUIElement"
		tell _selection to perform action "AXShowMenu"
	end tell
end tell

But a left click is completely beyond me.

I'm not sure this will provide what you want, but maybe it will help.
Your revised script will return the KM frame (Top,Left,Width,Height) of the text area where the caret (text cursor) currently resides.
You could use the output of this with the KM Move or Click Mouse action

tell application "System Events" to set frontApp to name of first process whose frontmost is true

tell application "System Events"
  tell application process frontApp
    set _selection to value of attribute "AXFocusedUIElement"
    --    tell _selection to perform action "AXShowMenu"
    set frameSel to value of attribute "AXFrame" of _selection
    set posSel to position of _selection
    set sizeSel to size of _selection
  end tell
end tell

set AppleScript's text item delimiters to ","

--- Return Top,Left,width,height ---
return (posSel & sizeSel) as text

-->2591,144,624,1150

Hey @JMichaelTX, is there a way to use a variable to the feed the numbers into the Move or Click Mouse Action? I am not seeing how I could feed these numbers to the click action.

Yep, just enter the Variable Name instead of the number.

Example:
image

1 Like

I didn't know how to do that either and need to know. I had no idea.