If one has selected some text in Google Chrome, and then uses cliclick to right click on this text in order to pull up the context menu for the selection, the text will no longer be selected. I would like the text to remain selected/highlighted after the right-click occurs (just like what happens when one right-clicks manually).

Here is the AppleScript code that I am using to right-click (wherever the cursor is located when the script is triggered):

do shell script "/usr/local/bin/cliclick kd:ctrl c:+0,+0"

Oddly enough, the issue only occurs in Google Chrome. If I run the AppleScript in Notes.app, TextEdit, Microsoft Word, Script Editor, Finder, Safari, etc. the selection remains highlighted after the right-click occurs.

Here is what I want to happen when the script is triggered:


(If you are wondering how I achieved this desired result while in Chrome, I simply right-clicked manually.)

Here is what actually happens when the above code is triggered:


Observe how PleaseRemainHighlighted goes from being selected to unselected.

Note: In the above GIF screen capture, the selected text happens to be editable. But the issue persists in Google Chrome whether the selected text is editable or uneditable.

I wanted to install MouseTools to see if this issue was unique to cliclick. But I can't figure out how to install MouseTools.

  • I installed MouseTools by placing the compiled command line tool (i.e., the Unix executable file) in the folder: /usr/local/bin/. Now I am trying to figure out how to right-click at the current cursor location. do shell script "/usr/local/bin/MouseTools -rightClick" isn't doing anything for me. Mar 15, 2017 at 23:02
  • It is strange that MouseTools -rightClick does not work in any app. Also, I'm not sure if you've already found this out or not, but manually pressing control + left click in Chrome does in fact keep the selection selected (for what it's worth). Mar 16, 2017 at 0:03
  • After the context menu is displayed, a choice in the context menu is selected. This question is about user experience. Functionally, whether the selected text is highlighted or not, the user can still access the context menu and proceed with selecting the desired context menu item. However, when the selected text is not highlighted, it is confusing and not ideal; the user is unsure what text exactly the context menu item will receive as its input. Mar 16, 2017 at 1:28
  • I don't see how it is doublespeak. You asked, "What comes after the control-click to bring up the context menu?" Nothing. That's where the script ends. The user can then select any one of the context menu items. Do you want to know every context menu item? "Search Google," "Search email," "Search Wikipedia," "Open in new window," etc. I do not see how the individual context menu items are relevant to my question. Mar 16, 2017 at 2:08

1 Answer 1


A workaround for "Google Chrome" (also work on any application): use dd:x,y and du:x,y

It's for a drag and drop, but it's a simple click when you put the same coordinates, like this:

do shell script "/usr/local/bin/cliclick kd:ctrl dd:. du:." -- mouseDown and mouseUp at the current cursor location

  • Amazing, thank you! Your code works perfectly in Chrome, and in every other application, whether the text is editable or uneditable. Mar 16, 2017 at 4:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .