Skip to content

Instantly share code, notes, and snippets.

@thomasjao
Created December 8, 2013 03:53
Show Gist options
  • Save thomasjao/7853169 to your computer and use it in GitHub Desktop.
Save thomasjao/7853169 to your computer and use it in GitHub Desktop.
Using UI elements to access unsupported application "Dictionary"
(* Appliction "Dictionary" doesn't support AppleScript. However, we can control this application via UI elements
of System Events. Following example show how to access various parts of "Dictionary" *)
tell application "Dictionary"
activate
tell application "System Events" to tell process "Dictionary"
UI elements of window 1
(* Access Spot light, enter searching word in the spotlight *)
set value of text field 1 of group 3 of tool bar 1 of windows to "challenge"
(* Get matched words/phrases list on the side bar of "Dictionary" *)
value of text field 1 of row 2 of table 1 of scroll area 1 of splitter group 1 of window 1
(* Get displayed word/phrase *)
value of static text of UI element 1 of UI element 1 of scroll area 1 of scroll area 2 of splitter group 1 of window 1
(* Accessing specific dictionary *)
radio buttons of radio group 1 of window 1
(* Access additional dictionaries that doesn't shown due to insufficient window width *)
click menu button 1 of window 1
(* Content of dictionary *)
say value of static text of group 1 of UI element 1 of scroll area 1 of scroll area 2 of splitter group 1 of window 1 as string using "Alex"
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment