Using Alfred for Efficient Word Lookup with Eudic Dictionary

· 1 min read

Eudic Dictionary is currently my only dictionary for word lookup, but the overall operation experience is still not efficient, so I plan to spend some time polishing it.

Complaints About Current Eudic

Before polishing, let me first complain about things I find annoying

  1. For word selection and lookup, if automatic word selection is enabled, word lookup icons will always be displayed everywhere, which is very annoying for someone who pursues simplicity like me. With manual word selection, every time I want to look up a word, I have to manually type the word again for searching.
  2. Cannot achieve one-click pronunciation - either choose automatic pronunciation after word lookup, or need cursor operations to select and trigger pronunciation.

Usage Flow Design

Since I want to polish it, let me first set a goal. The diagram below shows the operation flow I designed, which solves 2 pain points:

  1. After invoking Eudic Dictionary, no need to manually input the target word again
  2. One-click American pronunciation

Technology

  1. Apple Script to implement app operations for word lookup and pronunciation
  2. Alfred to implement getting cursor selection content and hotkeys

Eudic Settings

Disable hotkey settings

Automatic Word Search Execution


tell application "Eudic"
	activate
	show dic with word "{query}"
end tell

One-Click Pronunciation

on alfred_script(q)
tell application "Eudic"
	activate
	set windowName to the name of the front window
	speak word with word windowName
end tell
end alfred_script

Note: Eudic’s one-click pronunciation is American pronunciation, which is exactly what I need. If it’s not, then this method cannot be used, and you would need to implement controlling cursor operations on GUI elements.

Final Alfred Workflow

Notes:

  1. The hotkeys are set this way because my current design uses ⌘ ⌥ combination for system-level shortcuts, and ⌘ ⇧ combination for application-level shortcuts. E means eudic, s means speak
  2. The reason the first workflow needs to add launch is to bring the app to front. The online solution set frontmost to true doesn’t work.

Workflow download link: Click here

Final Result

The effect of the second one-click pronunciation cannot be demonstrated, experience it yourself.

AppleScript Usage Tips

During this polishing process, I also learned about Apple Script. There’s actually very little documentation available, so I’ll record some commonly used tips here.

Apple Suite

For individual apps, what actions we can perform depends on the Apple Suite. Open Script Editor, press ⌘ ⇧ O, select the specific app, and you can see the corresponding class properties and functions.

Log Printing

log hello

Variable Setting

set name11 to "1111"

Final Thoughts

Now word lookup is more efficient than before, Perfect!