[MacRuby-devel] Ruby scripting of OSX Leopard - pointer needed

Alan Skipp al_skipp at fastmail.fm
Tue Feb 24 08:05:25 PST 2009


One way of achieving this is by using rb-appscript, which you can  
install as a rubygem:
http://appscript.sourceforge.net/rb-appscript/index.html

There's also the Scripting Bridge:
http://developer.apple.com/documentation/Cocoa/Conceptual/RubyPythonCocoa/Articles/UsingScriptingBridge.html#/ 
/apple_ref/doc/uid/TP40005424-SW1

The rb-appscript version of your Applescript would look like this:

require "rubygems"
require "appscript"
include Appscript

res = (`/usr/sbin/system_profiler SPDisplaysDataType | grep  
Resolution`).split
width,height = res.grep(/\d+/)

window = app("System  
Events").processes[its.frontmost.eq(true)].windows[1]
window.position.set([0, 22])
window.size.set([width, height])

-al


More information about the MacRuby-devel mailing list