Tip: Look up in thesaurus or dictionary tab of choice


If you want to use the Scrivener “Look up in dictionary” option to lookup a word in the dictionary but use a different tab in the dictionary app (EG the British Dictionary). You can accomplish this with a bit of configuration, applescript and a thirdparty app (I use Spark).

In System Preferences assign a keyboard shortcut to the “Look Up in Dictionary and Thesaurus”. I’ve assigned Shift+Command+D.

In Spark setup a new applescript action with the script below. I assign this to Command+K.

Now when you select a word, hit command+K the dictionary will open and switch to your tab of choice.

There’s other ways to accomplish the same thing. My way is a bit convoluted but I’ve found these “Send a key-press event to an application” to be really reliable.

-- But only if Scrivener is running!
if appIsRunning("Scrivener") then
	tell application "Scrivener" to activate
	tell application "System Events" to keystroke "D" using {command down, shift}
        -- delay is to allow dictionary to appear and start responding, even after Lion switch spaces event
	delay 0.6
	tell application "Dictionary" to activate
        -- Change 5 to number of tab you want
	tell application "System Events" to keystroke "5" using {command down}	
	--End of app running check
end if

-- Routine to check if an app is running
on appIsRunning(appName)
	tell application "System Events"
		set isRunning to ((application processes whose (name is equal to appName)) count)
	end tell
	if isRunning is greater than 0 then
		return true
		return false
	end if
end appIsRunning

You could also select your preferred tabs, and set your preferred order, in Dictionary’s preferences…

Yes, but that wouldn’t give me one shortcut for one tab, another for another.