Emulate Right Click at Cursor Location

Is there a way to achieve this in Keyboard Maestro?

Found that when I'm typing in slack and I misspell a word, going to my mouse and right clicking that word takes time.

Since slack doesn't have a spell check quick key, I'm wondering if I could program a macro to right click where my cursor is so I don't have to go to my mouse to achieve this.

@MealTicketAlex Try this:

Right Click at Cursor.kmmacros (37 KB)

Macro screenshot

No need to resort to AppleScript when KM provides a built-in action for this:
Test Right Click.kmmacros (2.2 KB)

Click to see image of macro

@tiffle Ah, but he wants to click at the text cursor location, not the mouse location.

1 Like

Should've gone to specsavers :eyeglasses:


@MealTicketAlex That do it for ya?

Unfortunately, no.
Screen Shot 2022-05-03 at 2.16.05 PM

@MealTicketAlex What app are you trying to use it in? Try it in Textedit and let me know if it works there.

Bear in mind, you have to select the text before running the script.

Slack is not a native Mac app as it is written in Javascript (whether running as Electron App or in web browser) and the Applescript code provided by noisneil can only work with native Mac app.

To explain technically, the Applescript code by @noisneil is unable to get the AXFocusedUIElement (since Slack is not true native App), hence the error occurs.

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" # <---  _selection become Missing Value
        tell _selection to perform action "AXShowMenu"
	end tell
end tell

I appreciate yours and @noisneil 's help either way! Thank you

1 Like

Interested to know if this modified version of the script works for you:

If not, here's an idea that might solve the same problem a different way...