When I press Command-C or Command-X over the selected (highlighted) text how is that string getting "grabbed" and pasted onto the clipboard? Or similarly when I select a word and 3-finger tap, how is that string being passed to the Lookup functionality? Moreover, this works even if I have highlighted a text in one window, then I highlight another in a different window, but only the second one gets picked up (as opposed to stuff that was highlighted on different pages). How are these selected texts being distinguished?

(Not sure if the copy&cut and the lookup method work the same way but I just wanted to give examples)

enter image description here

I am trying to automate a process whereby I need to "grab" a highlighted word and save it to a variable. I found the application BetterTouchTools which lets me bind code (Shell script, Apple script, or Javascript) to hotkeys / gestures. But I can't figure out how I'm supposed to take a string as input by simply hihglighting it.

  • 1
    The system takes care of most of that, and individual applications can also keep track of what they do. Automator can also be used to create a service that will take the selection (text, files, whatever) and pass it on to the workflow.
    – red_menace
    Commented May 26, 2020 at 23:40
  • If I just simply want to save a highlighted word, before passing it on to processing, how would I do that?
    – Bn.F76
    Commented May 26, 2020 at 23:46
  • Answering my question above: you can create a Service (aka Quick Action) via Automator. You select 'Run Shell Script' or 'Run Apple Script', pass the input as argument and do whatever you want with it. helpful link: apple.stackexchange.com/a/276839/363979
    – Bn.F76
    Commented Jun 2, 2020 at 12:25


You must log in to answer this question.

Browse other questions tagged .