Guide

Getting an Application Object

As you just learned in Starting Out, you can locate an application by passing its name to OSA.app(). However, there are also several other ways.

You can also locate an application by providing its signature (as a four character string), or bundle ID:

OSA.app(:signature => 'hook')

OSA.app(:bundle_id => 'com.apple.iTunes')

If the application you want to control hasn’t been installed in one of the standard applications locations, RubyOSA may have some trouble locating it. You can provide the full path of the application to work around this:

OSA.app(:path => '/Somewhere/Applications/MyApp.app')

Note that OSA.app('iTunes') is a convenience shortcut to OSA.app(:name => 'iTunes').