Trying to learn OS X application scripting with Ruby and appscript, but have run into a problem with a small example meant to demonstrate the various methods of getting OS X application objects.
That last line (trying to do it by bundle ID) throws this error:
FWIW, I run the x64 kernel in 10.6.5. This is NOT school, BTW. Just doing this for fun.
Thanks!
Code:
#!/usr/bin/ruby
# this ruby script demonstrates different methods of getting OS X application
# objects using appscript (of class Appscript::Application). The method new of
# this class is private; thus we use another method called Appscript.app. This
# calls Appscript::GenericApplication.new for you and generates an instance of
# class Appscript::Application.
# by_name
# by_id
# by_creator
# by_pid
# by_url
require 'rubygems'
require 'appscript'
require 'osax'
## by_name
Appscript.app.by_name("iTunes")
# may be shortened thus:
Appscript.app("iTunes.app")
## by_id
puts OSAX.osax.info_for(
MacTypes::Alias.path("/Applications/iTunes.app"))[:bundle_identifier]
#=> com.apple.iTunes
That last line (trying to do it by bundle ID) throws this error:
Code:
/Library/Ruby/Gems/1.8/gems/rb-appscript-0.5.3/lib/osax.rb:153:in `initialize': OSAX::ScriptingAddition can't dynamically retrieve scripting addition terminology within a 64-bit process. (RuntimeError)
from /Library/Ruby/Gems/1.8/gems/rb-appscript-0.5.3/lib/osax.rb:102:in `new'
from /Library/Ruby/Gems/1.8/gems/rb-appscript-0.5.3/lib/osax.rb:102:in `osax'
from app_objects.rb:29
FWIW, I run the x64 kernel in 10.6.5. This is NOT school, BTW. Just doing this for fun.
Thanks!