Jump to content

Make a dictionary workflow for GoldenDict with function just like the 'Define {query}' native to Alfred


Recommended Posts

Posted

Dear all,

 

I am a current student studying English literature and therefore using the native dictionary.app in a Mac is not enough. So I downloaded GoldenDict with OED equipped. I was trying to build a workflow which I hope will function exactly like the 'define {query}' feature in Alfred. Basically, I want to have the GoldenDict window come to front and give me the definition after typing the keyword 'gold' and hit [space] and then type my {query} in Alfred.

 

I am learning to to build a workflow from scratch for my own so I don't have to come to bother you guys every time I have some issues but for now I am a pretty a layman in both automation and programming in general. So any advice or suggestion will be appreciated. Hope to be able to contribute to Alfred community some day. Thanks again.

 

Lawrence

Posted

Welcome @mint_lab,

 

On 10/27/2019 at 11:33 AM, mint_lab said:

I am learning to to build a workflow from scratch for my own so I don't have to come to bother you guys every time I have some issues

 

Thumbs up! We do enjoy helping people who want to learn.

 

On 10/27/2019 at 11:33 AM, mint_lab said:

for now I am a pretty a layman in both automation and programming in general

 

However, your project might not be suitable for a beginner. We’ll need more information to determine if it’s even possible.


First, something you may not have considered: are you aware you can add dictionaries to Apple’s Dictionary app? It comes with a bunch of them and you can download more online. It may be that the particular dictionary you want has a compatible version.


If GoldenDict it’s your only option, it will either need to support AppleScript (best option)—which from a cursory glance it looks to not be the case (but you should ask the developer)—or store dictionaries in an accessible format you can parse with some programming.

  • 1 year later...
Posted

I use AppleScript to send the {query} to GoldenDict's search box. Simply use "Run NSAppleScript" and connect it to a keyword/shortcut trigger.

 

Here is the code:

 

on alfred_script(SelectedText)

tell application id "org.goldendict"
	activate
end tell

tell application "System Events"
	tell process "GoldenDict"
		repeat until window 1 exists
		end repeat
		set value of text field 1 of window 1 to SelectedText
		set (text field 1 of window 1)'s focused to true
	end tell
	key code 36
end tell

end alfred_script

 

Posted
39 minutes ago, agboh said:

Simply use "Run NSAppleScript"

 

Better to use a Run Script with Language = /usr/bin/osascript (AS) than Run NSAppleScript wherever possible. Run NSAppleScript blocks Alfred while it's running. Run Script doesn't block.

Posted
48 minutes ago, deanishe said:

 

Better to use a Run Script with Language = /usr/bin/osascript (AS) than Run NSAppleScript wherever possible. Run NSAppleScript blocks Alfred while it's running. Run Script doesn't block.


Great input. Thank you!

  • vitor changed the title to Make a dictionary workflow for GoldenDict with function just like the 'Define {query}' native to Alfred

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...