LandonSchropp
LandonSchropp

Reputation: 10234

rb-appscript not working in Mountian Lion

I'm using rb-appscript. The following line worked fine in Lion but doesn't seem to work in Mountain Lion:

desktop_bounds = Appscript.app.by_name("Finder").desktop.window.bounds.get

I have two questions:

  1. Is there a way to get fix this in Mountain Lion.
  2. I see the rb-appscript project is no longer being maintained. Is there a better alternative?

Upvotes: 1

Views: 499

Answers (2)

bmorgan
bmorgan

Reputation: 525

I think this is the same issue that arose for iTunes 10.6.3: See here for the iTunes discussion (along with a link to a much fuller debate about the future of appscript following a post by Dr. Drang) and a fix by Matt Neuburg.

The problem seems to be that appscript can no longer fetch the dictionary for the application (in this case Finder), so any calls to application-specific methods break. Matt has posted a script at https://github.com/mattneub/appscript/tree/master/rb-appscript that provides an alternative approach to fetching the dictionary. You can use this in the following way to restore functionality:

require 'Appscript'

$RUBY_DIR = '/Users/ben/Documents/Code/rb-appscript'

def app_module( id )
  require "#{$RUBY_DIR}/sdefToRBAppscriptModule.rb"
  f = FindApp.by_id(id)
  return SDEFParser.makeModule(f)
end

finder = Appscript.app("Finder", app_module('com.apple.finder'))

desktop_bounds = finder.desktop.window.bounds.get
p desktop_bounds

Upvotes: 2

Atastor
Atastor

Reputation: 741

Just my two cent: MacRuby as a replacement is more Ruby but defintively less Appscript than rb-appscript. But it should get the job done.

Upvotes: 1

Related Questions