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

Lachie lachiec at gmail.com
Tue Feb 24 14:18:42 PST 2009


Two other notes: Ruwin uses Rubycocoa, not Macruby. It also uses
NSScreen to get screen info rather than grepping system_profiler
output


On Wed, Feb 25, 2009 at 9:17 AM, Lachie <lachiec at gmail.com> wrote:
> The ScriptingBridge approach is more involved, because the size and
> position accessors don't seem to resolve automatically...
>
> My Ruwin library is an example of how to do it though:
>
> http://github.com/lachie/ruwin
> http://github.com/lachie/ruwin/blob/20a23ac330f65b4930c1b26be2ce463e05a516c7/ruwin.rb
>
> :lachie
> http://smartbomb.com.au
> http://www.flickr.com/photos/lachie/
>
>
>
> On Wed, Feb 25, 2009 at 3:05 AM, Alan Skipp <al_skipp at fastmail.fm> wrote:
>> 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
>> _______________________________________________
>> MacRuby-devel mailing list
>> MacRuby-devel at lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>>
>


More information about the MacRuby-devel mailing list