MacOS – way to track the look ups in the OSX dictionary

dictionarylook-upmacos

I am a non-english native speaker and therefore use the OSX's built-in look up service (three-finger tab and cmd+L in the spotlight search field) quite a lot.

I was wondering if there was a way to keep track of or record the words I have looked up? (Applescript perhaps?)

EDIT: When I three-finger tab it also gives me definitions from wikipedia. Could I utilise this, i.e. track the requests Dictionary.app sends to wikipedia.org, to track which words I look up?

Best Answer

You can't do this with the normal three-finger tap, but if you make an Automator service with some Applescript, you can trigger it on a keyboard shortcut. (Note: This shows a full dictionary window, not a nice popover. I don't think there's a way to do it like that.)

To make this service, open Automator.app, in the /Applications/ folder.

Choose Service. Service selected in the Automator startup sheet

Then, in the Library on the left, search for AppleScript, and drag Run Applescript over.

Here's the script to paste in.

on run {input, parameters}

    set logPath to "Desktop/words.txt"
    --You can change the path in quotes
    --to the file you want to store the
    --words you look up.

    set lookUpWord to quoted form of (input as string)
    --This sets the word to the selected text, from input.

    do shell script "cd; echo " & lookUpWord & " >> " & quoted form of logPath
    --This appends the word to the log file.

    do shell script "open dict://" & lookUpWord
    --This opens the word in Dictionary.

    return input
end run

Click the hammer to compile. It should look like this: enter image description here

The last thing to do is assign a keyboard shortcut. Save the workflow (I called mine "look up"), and open System Preferences. Go to Keyboard > Keyboard Shortcuts > Services.

Select your service (It should be under Text), then click "add shortcut" and type the shortcut you'll be using to trigger it. enter image description here I like to use command ⌘+control ^ and a letter, because those are almost guaranteed not to be already in use by an application.

That should work! Just select a word by double-clicking, then type your keyboard shortcut to use it.