Jump to content

Wanted to create a workflow for an dictionary app to show explanation but got stuck

Recommended Posts

Hello guys! I love the Alfred functions for Mac build-in dictionary and want to create a workflow like 'Define {query}' for another dictionary appoxford_oalecd9/牛津高阶第9版. But I'm totally a beginer of Alfred workflow and Apple Script. So, I looked up a lot and learned from others' similar workflows for eudic on the Internet, and started creating one by myself. However, the script seemed to have some errors and I really need your generous help!


I used a keyword to run Appe Script and the code are shown in Figure 1. It didn't work at all but I can't see what the problem is... Since the app doesn't function like eudic, I can't code directly like 'show dic with word "{query}". So I found an alternative solution to paste {query} on the input field of the dictionary app. With the help of UI Browser app, I found the location of the input field and set value of it. I think the logic is correct but I'm not confident with the grammar of Apple Script. Can you guys help me to find my bugs?


Thanks a lot!



Link to comment
16 hours ago, vitor said:

Welcome @Yumin,


Start by avoiding with input as {query}. There is a reason why with input as argv is the default, it saves worrying about the escaping. The Mac App Store doesn’t let me download 牛津高阶第9版 so I can’t test, but start by looking at the debugger to see what errors you get.


Thank you for your reply and attempt, @vitor :) 


Yes,the app 牛津高阶第9版 is not free and is an English-Chinese version of Oxford Dictionary, so I guess it can only be downloaded in mainland China because of the copyright.


Maybe I'm aware of what the problem is, which is that the app is not scriptable, rather than grammar errors. I'd tried to view its scripting dictionary in Script Editor but failed as Fig 1 shown. I also wrote the code below in Script Editor to validate, and it sent back "System Events got an error: Can’t set window "oxford_oalecd9" of process "oxford_oalecd9" to "hello"." So, I suppose I can't write a workflow as planned.


image.thumb.png.040c6c9d8180d1325e14958deceeb836.png  Fig 1


set theQuery to "hello"

tell application "牛津高阶第9版"
end tell

delay 1

tell application "System Events"
	tell process "oxford_oalecd9"
		set value of text field 1 of group 1 of group 2 of group 1 of group 1 of group 1 of group 1 of window "oxford_oalecd9" to theQuery
	end tell
end tell


Edited by Yumin
Link to comment

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...