# MacOS – AppleScript: How to right-click, without deselecting text, in Google Chrome

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.

A workaround for "Google Chrome" (also work on any application): use dd:x,y and du:x,y
do shell script "/usr/local/bin/cliclick kd:ctrl dd:. du:." -- mouseDown and mouseUp at the current cursor location