Using Automator Programmatically ("Behind the Scenes")

(This is my first post, and I'm very happy to be joining the Apple Discussions community. 🙂 )

I'm very new to Cocoa/Objective-C development. As a matter of fact, I'm a recent Computer Science graduate who wants to move into the Mac development field. I have a strong background in C++/Java/OOP in general, so I figured I'd try my hand at developing a little Cocoa application to get the feel for Objective-C.

I want to make an application that makes use of OS X's built-in New Oxford American Dictionary. I tried exploring the raw data files for the dictionaries in /Library/Dictionaries, but it seems that the non-Apple Dictionaries are encrypted (or are at least not in immediately usable form -- researching this online gave me nothing useful).

I then noticed that 10.5's Automator comes with a "Get Definition of Word" action that does exactly what I want: give a single-word text input and return a simple text output with the word's definition. So I thought, "Great. I'm sure I can figure out how to use Automator 'behind the scenes' in Objective-C to look up definitions for my program." (In case you're wondering why the heck I want to partially replicate Dictionary.app's functionality, I'm trying to create a simple Hangman app that draws words from the built-in Dictionary word bank and uses their definitions as a "hint" eventually.)

After looking at the /Developer/Examples/Automator folder, I thought that these examples would surely provide what I was looking for, but it seems as if all the examples simply create Automator actions; i.e., Automator is launched when these example projects are compiled and run. What I'm looking for is a way to make use of Automator in my project without the user knowing about it (or at least seeing the Automator application launch every time I want a new definition).

Therefore, ...

1) Does anyone know how to make sure of Automator "behind the scenes?"
2) Can the Automator controls in Interface Builder be used without user input?
3 a) Am I going about this in the entirely wrong way (I would prefer not using an online dictionary resource if possible)?
3 b) Should I consider a different method for achieving this effect?
3 c) Should I forget about this altogether?

I'm guessing that one of 3)'s options is what I'll be told to follow. 🙂 In any case, any information about this from someone more knowledgeable than me (i.e., mostly everyone) would be appreciated. 🙂

PowerBook G4, Mac OS X (10.5.2)

Posted on May 13, 2008 8:55 PM

Reply
6 replies

May 14, 2008 7:02 AM in response to GuardianAtomos

I think you would be better off looking at the Apple Scripting options for the Dictionary. You can use the Scripting Bridge to control the Dictionary from your Applications. You don't want to use Automator. That is just a scripting interface to Apple Script and it is horribly slow. I have one Automator script and it takes about a minute to boot up and start doing what it is supposed to.

May 14, 2008 2:00 PM in response to GuardianAtomos

Applications use AppleScript internally all the time. It isn't noticeable.

If you are scripting the dictionary, you can't really hide that it is running. There is a way to pop-up a mini dictionary window with a hotkey (Ctrl-Command-D), but I don't know how to do that. It may be a service or something. Emulating that behavior seems to be your best route.

If this is what you want to do, you might want to start a new thread. This is far from using Automator and different people would be interested in using the Dictionary this way and would have a better answer. I will look it up myself when I get home and back to my Mac (and assuming I remember). I tried to change the topic but it only applied to my response.

Message was edited by: etresoft

May 14, 2008 2:44 PM in response to etresoft

Hm. Yeah, I guess that might be my only option. Really, though, I just want to interact with Dictionary just to grab a definition to be shown within my app at a later point. I guess if I can't interact with the Dictionary without it being launched or even its service ("Look Up in Dictionary") appearing in a popup window, I don't know if I'll be able to achieve the transparency I was hoping to achieve. Too bad the raw Oxford dictionary data files aren't in a readable format like the raw Apple dictionary data files.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Using Automator Programmatically ("Behind the Scenes")

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.