From lachiec at gmail.com Sat Feb 3 23:25:52 2007 From: lachiec at gmail.com (Lachie) Date: Sun, 4 Feb 2007 15:25:52 +1100 Subject: [Rubyosa-discuss] Is it possible to cast OSA objects? Message-ID: <2c5e719e0702032025v3f3b7c6agcba30ffddd13cce7@mail.gmail.com> Hi, Thanks very much for RubyOSA! I'm trying to drive OmniGraffle with RubyOSA. In particular I'm dealing with an existing Table object. From the OG dictionary: table?n [inh. group > graphic > item] : A tabular grouping of graphics The first problem is that there's no tables accessor on a canvas object, only groups and graphics. I can get the Table I want via the groups accessor, only it comes back as its superclass, Group. p table.properties["class"] #=> OSA::OmniGraffleProfessional::Table p table.class #=> OSA::OmniGraffleProfessional::Group None of the Table-specific methods such as columns and rows are available on the returned object Is there any way that I can "cast" this object to Table? Is there some other strategy I should look into? cheers, Lachie http://lachie.info/ http://www.flickr.com/photos/lachie/ From lrz at chopine.be Sat Feb 3 23:40:36 2007 From: lrz at chopine.be (Laurent Sansonetti) Date: Sat, 3 Feb 2007 20:40:36 -0800 Subject: [Rubyosa-discuss] Is it possible to cast OSA objects? In-Reply-To: <2c5e719e0702032025v3f3b7c6agcba30ffddd13cce7@mail.gmail.com> References: <2c5e719e0702032025v3f3b7c6agcba30ffddd13cce7@mail.gmail.com> Message-ID: Hi Lachie, Actually, as you might have guessed, RubyOSA returns you directions to objects based on the scriptable definition of the application. In that case, it gives you a Group object because the method defined in the sdef explicitly returns an object of this kind. However you can resolve the returned object by calling the #get method on it. This should return you an object of the right class. This is sometimes required, unfortunately. Note that you can also set the OSA.lazy_events variable to false and this will make RubyOSA resolving all objects. This is not the default behavior because it impacts a bit the performance (as this requires an apple event to be sent every time). This isn't documented yet but we are working on. HTH, Laurent On Feb 3, 2007, at 8:25 PM, Lachie wrote: > Hi, > Thanks very much for RubyOSA! > > I'm trying to drive OmniGraffle with RubyOSA. In particular I'm > dealing with an existing Table object. > > From the OG dictionary: > table?n [inh. group > graphic > item] : A tabular grouping of > graphics > > The first problem is that there's no tables accessor on a canvas > object, only groups and graphics. > I can get the Table I want via the groups accessor, only it comes back > as its superclass, Group. > > p table.properties["class"] #=> OSA::OmniGraffleProfessional::Table > p table.class #=> OSA::OmniGraffleProfessional::Group > > None of the Table-specific methods such as columns and rows are > available on the returned object > > Is there any way that I can "cast" this object to Table? Is there some > other strategy I should look into? > > cheers, > Lachie > http://lachie.info/ > http://www.flickr.com/photos/lachie/ > _______________________________________________ > Rubyosa-discuss mailing list > Rubyosa-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/rubyosa-discuss From keenan at thebrocks.net Mon Feb 5 09:53:24 2007 From: keenan at thebrocks.net (Keenan Brock) Date: Mon, 5 Feb 2007 09:53:24 -0500 Subject: [Rubyosa-discuss] iPhoto and rubyOSA Message-ID: <91506680702050653v7ed46c4by46dc3ec797fbdab4@mail.gmail.com> Hi All, Just wanted to share that rubyOSA works really well with iPhoto. As you know, iPhoto is lacking in the apple script support. iPhoto Library Manger installs a great plugin that allows Apple Script access to all the attributes and actions. Brian Webster (the author) really stepped up where Apple screwed up. When prompted, he said he didn't support this behavior and may change the API at any time. So I haven't been comfortable submitting code examples to this project when I rely so heavily on a third party plugin, let alone one that the author does want to support. Anyone else working with iPhoto? Any other options that enhance iPhoto so it is usable by Apple Script and/or rubyOSA? Thank you all for such a great tool. I've tried and bought books to learn Apple Script but after a few years I realized it just wasn't for me. This has allowed me to get the same functionality but do so in an enjoyable way. Thanks, Keenan From kbrbosa at thebrocks.net Mon Feb 5 13:22:14 2007 From: kbrbosa at thebrocks.net (Keenan Brock) Date: Mon, 5 Feb 2007 13:22:14 -0500 Subject: [Rubyosa-discuss] iPhoto and rubyOSA In-Reply-To: <91506680702050653v7ed46c4by46dc3ec797fbdab4@mail.gmail.com> References: <91506680702050653v7ed46c4by46dc3ec797fbdab4@mail.gmail.com> Message-ID: <91506680702051022v7ff95196g449fa7d9a3c100af@mail.gmail.com> Hi All, Just wanted to share that rubyOSA works really well with iPhoto. As you know, iPhoto is lacking in the apple script support. iPhoto Library Manger installs a great plugin that allows Apple Script access to all the attributes and actions. Brian Webster (the author) really stepped up where Apple screwed up. When prompted, he said he didn't support this behavior and may change the API at any time. So I haven't been comfortable submitting code examples to this project when I rely so heavily on a third party plugin, let alone one that the author does want to support. Anyone else working with iPhoto? Any other options that enhance iPhoto so it is usable by Apple Script and/or rubyOSA? Thank you all for such a great tool. I've tried and bought books to learn Apple Script but after a few years I realized it just wasn't for me. This has allowed me to get the same functionality but do so in an enjoyable way. Thanks, Keenan From lsansonetti at apple.com Fri Feb 16 21:46:54 2007 From: lsansonetti at apple.com (Laurent Sansonetti) Date: Sat, 17 Feb 2007 03:46:54 +0100 Subject: [Rubyosa-discuss] accessing remote applications Message-ID: <563313A4-5245-4043-B942-9512C2E723E7@apple.com> Hi, With the SVN version it's now possible to control applications on remote machines! OSA.app('iTunes', :machine => 'my-machine.local').play It works by sending remote Apple Events. The target machine must have the "Remote Apple Events" option checked in the "Sharing" preferences. Also, note that you can pass the username and password to OSA.app, using respectively the :username and :password keys. Enjoy, I will release 0.3.0 very soon now :-) Laurent From dbenne at gmail.com Fri Feb 16 23:52:05 2007 From: dbenne at gmail.com (Don Benne) Date: Fri, 16 Feb 2007 22:52:05 -0600 Subject: [Rubyosa-discuss] Scripting Pages Message-ID: Has anyone done any scripting with Pages? I'm not sure if I found a bug or just doing something wrong. I think what I've got is pretty simple: app = OSA.app('Pages') app.open("/Users/dbenne/Documents/testing.pages") docs = app.documents() pages = docs[0].pages pages.each do |page| puts page.page_number() end but it seg faults: /opt/local/lib/ruby/gems/1.8/gems/rubyosa-0.2.0/lib/rbosa.rb:370: warning: already initialized constant TWFT (eval):2: [BUG] Segmentation fault ruby 1.8.5 (2006-12-25) [i686-darwin8.8.1] Abort trap I'm using Ruby 1.8.5 from MacPorts and installed RubyOSA via rubygems. I wrote a successful iTunes script so I'm pretty sure my install is ok. Thanks for this great tool! Don From lsansonetti at apple.com Sat Feb 17 13:36:01 2007 From: lsansonetti at apple.com (Laurent Sansonetti) Date: Sat, 17 Feb 2007 19:36:01 +0100 Subject: [Rubyosa-discuss] Scripting Pages In-Reply-To: References: Message-ID: Hi Don, The crash is due to a bug in RubyOSA 0.2.0, the SVN version has been fixed (and 0.3.0 is going to be released soon). When running your sample with the SVN version I get: ./src/lib/rbosa.rb:508:in `__send_event__': application returned error: Unknown error (8), with message: NSInternalScriptError (RuntimeError) from ./src/lib/rbosa.rb:508:in `page_number' from test.rb:8 from ./src/lib/rbosa.rb:193:in `each' from ./src/lib/rbosa.rb:193:in `times' from ./src/lib/rbosa.rb:193:in `each' from test.rb:7 Which is a strange error, but writing the equivalent AppleScript tell application "Pages" get page number of page 1 of document 1 end tell Returns me the same exact error. So I can only say that it's not a RubyOSA issue :) Now I will investigate a bit, maybe this is a Pages bug. Laurent On Feb 17, 2007, at 5:52 AM, Don Benne wrote: > Has anyone done any scripting with Pages? I'm not sure if I found a > bug or just doing something wrong. I think what I've got is pretty > simple: > > app = OSA.app('Pages') > app.open("/Users/dbenne/Documents/testing.pages") > docs = app.documents() > pages = docs[0].pages > pages.each do |page| > puts page.page_number() > end > > but it seg faults: > /opt/local/lib/ruby/gems/1.8/gems/rubyosa-0.2.0/lib/rbosa.rb:370: > warning: already initialized constant TWFT > (eval):2: [BUG] Segmentation fault > ruby 1.8.5 (2006-12-25) [i686-darwin8.8.1] > > Abort trap > > I'm using Ruby 1.8.5 from MacPorts and installed RubyOSA via > rubygems. I wrote a successful iTunes script so I'm pretty sure my > install is ok. > > Thanks for this great tool! > Don > > _______________________________________________ > Rubyosa-discuss mailing list > Rubyosa-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/rubyosa-discuss From lsansonetti at apple.com Sat Feb 17 13:48:47 2007 From: lsansonetti at apple.com (Laurent Sansonetti) Date: Sat, 17 Feb 2007 19:48:47 +0100 Subject: [Rubyosa-discuss] iPhoto and rubyOSA In-Reply-To: <91506680702050653v7ed46c4by46dc3ec797fbdab4@mail.gmail.com> References: <91506680702050653v7ed46c4by46dc3ec797fbdab4@mail.gmail.com> Message-ID: Hi Keenan, Sorry for the late response! On Feb 5, 2007, at 3:53 PM, Keenan Brock wrote: > Hi All, > > Just wanted to share that rubyOSA works really well with iPhoto. > > As you know, iPhoto is lacking in the apple script support. iPhoto > Library Manger installs a great plugin that allows Apple Script access > to all the attributes and actions. Brian Webster (the author) really > stepped up where Apple screwed up. > > When prompted, he said he didn't support this behavior and may change > the API at any time. > > So I haven't been comfortable submitting code examples to this project > when I rely so heavily on a third party plugin, let alone one that the > author does want to support. Actually I never tried controlling iPhoto, I'm glad to hear your report :) Regarding the code samples, I guess that it would be great to have them even if they require this third party plugin (and that they may not work with upcoming versions of this plugin). Having them is still better than having nothing. So if you are willing to contribute some, feel free to! We will write a special README file in the sample/iPhoto directory where we will mention the third party plugin. Cheers, Laurent From hannu.kokko at iki.fi Mon Feb 26 01:00:29 2007 From: hannu.kokko at iki.fi (Hannu Kokko) Date: Mon, 26 Feb 2007 08:00:29 +0200 Subject: [Rubyosa-discuss] typecast error? Message-ID: <199BF2A7-2F65-4517-9430-F1FF4AF36F5A@iki.fi> Hi Following code #!/usr/bin/env ruby begin require 'rubygems'; rescue LoadError; end require 'rbosa' mm = OSA.app('Mindjet MindManager') docs = mm.documents front_document = docs.first front_document.central_topic.subtopics.each { |topic| puts topic.title } gives following error: undefined method `first' for # /Users/hannukokko/Documents/Ruby koodia/MusicJukebox/Ruby-1.rb:6 /Users/hannukokko/Documents/Ruby koodia/MusicJukebox/Ruby-1.rb:6: undefined method `first' for # (NoMethodError) I would have expected the mm.documents be an array that accepts the first as a method call? --h From jmacaulay at gmail.com Mon Feb 26 14:35:14 2007 From: jmacaulay at gmail.com (James MacAulay) Date: Mon, 26 Feb 2007 14:35:14 -0500 Subject: [Rubyosa-discuss] typecast error? In-Reply-To: <199BF2A7-2F65-4517-9430-F1FF4AF36F5A@iki.fi> References: <199BF2A7-2F65-4517-9430-F1FF4AF36F5A@iki.fi> Message-ID: The ObjectSpecifierLists provided by rbosa look like arrays, but aren't arrays. They have the [] method, however, so you should just be able to use front_document = docs[0] instead. James On 26-Feb-07, at 1:00 AM | Feb 26, Hannu Kokko wrote: > > Hi > > Following code > #!/usr/bin/env ruby > begin require 'rubygems'; rescue LoadError; end > require 'rbosa' > mm = OSA.app('Mindjet MindManager') > docs = mm.documents > front_document = docs.first > front_document.central_topic.subtopics.each { |topic| > puts topic.title } > > gives following error: > undefined method `first' for # > /Users/hannukokko/Documents/Ruby koodia/MusicJukebox/Ruby-1.rb:6 > /Users/hannukokko/Documents/Ruby koodia/MusicJukebox/Ruby-1.rb:6: > undefined method `first' for # > (NoMethodError) > > I would have expected the mm.documents be an array that accepts the > first as a method call? > > --h > _______________________________________________ > Rubyosa-discuss mailing list > Rubyosa-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/rubyosa-discuss From eivind at bramseil.com Sat Feb 24 20:03:25 2007 From: eivind at bramseil.com (=?ISO-8859-1?Q?Eivind_L=F8land-Andersen?=) Date: Sun, 25 Feb 2007 02:03:25 +0100 Subject: [Rubyosa-discuss] Run an applescript with RubyOSA Message-ID: <86C07433-9066-4E56-B5CE-DB2EEA9132D7@bramseil.com> Hi, I'm trying to run an applescript with RubyOSA. I've made a simple applescript, and saved it as an application in the applications directory. When I run the command: my_app = OSA.app('hello.app') ...I get this error (even with the lastest ruby): /usr/local/lib/ruby/gems/1.8/gems/rubyosa-0.2.0/lib/rbosa.rb:201: [BUG] Bus Error ruby 1.8.5 (2006-12-25) [i686-darwin8.8.1] All I need to do is to start an applescript from ruby along with some strings. Can this be done with RubyOSA? From bomberstudios at gmail.com Tue Feb 27 06:46:51 2007 From: bomberstudios at gmail.com (=?UTF-8?Q?Ale_Mu=C3=B1oz?=) Date: Tue, 27 Feb 2007 12:46:51 +0100 Subject: [Rubyosa-discuss] sdef merging, API changes In-Reply-To: <14148D8B-9954-40F2-B1B4-99ECEF7E12C0@apple.com> References: <14148D8B-9954-40F2-B1B4-99ECEF7E12C0@apple.com> Message-ID: On 1/30/07, Laurent Sansonetti wrote: > > It's now possible to merge a given scriptable definition into the > current application object. A #merge method has been added for this. > Example: > > ichat = OSA.app('iChat') > ichat.merge(:by_path => '/System/Library/ScriptingAdditions/StandardAdditions.osax') > ichat.beep(4) # will beep 4 times > > #merge also accepts :by_name, :by_bundle_id and :by_signature key/ values. > Hi there, could you please provide some more examples of merge? I'm trying to get it working with the latest SVN checkout but so far it does nothing :( Here's my code: begin require 'rubygems'; rescue LoadError; end require 'rbosa' app = OSA.app('iTunes') OSA.utf8_strings = true app.merge(:path => '/System/Library/ScriptingAdditions/StandardAdditions.osax') app.beep(4) And it provides me with a nice and clean nothing, neither beep, nor error :) Thanks in advance! -- Ale Mu?oz http://sofanaranja.com http://bomberstudios.com From jmacaulay at gmail.com Tue Feb 27 11:03:20 2007 From: jmacaulay at gmail.com (James MacAulay) Date: Tue, 27 Feb 2007 11:03:20 -0500 Subject: [Rubyosa-discuss] Run an applescript with RubyOSA In-Reply-To: <86C07433-9066-4E56-B5CE-DB2EEA9132D7@bramseil.com> References: <86C07433-9066-4E56-B5CE-DB2EEA9132D7@bramseil.com> Message-ID: <4F864AA6-2A23-42AC-BEC5-D1513686E697@gmail.com> If I understand correctly, then you don't need RubyOSA at all to do this. You can just use the plain-old-ruby syntax of backticks to call simple commands, which returns whatever output it produces: my_app_output = `hello.app` Or, if you need to programmatically interact with the program after it has started, via standard input and output, then you can use IO.popen("hello.app","w+"): http://www.rubycentral.com/book/ref_c_io.html#IO.popen -James On 24-Feb-07, at 8:03 PM | Feb 24, Eivind L?land-Andersen wrote: > Hi, > > I'm trying to run an applescript with RubyOSA. > > I've made a simple applescript, and saved it as an application in the > applications directory. > When I run the command: > my_app = OSA.app('hello.app') > > ...I get this error (even with the lastest ruby): > /usr/local/lib/ruby/gems/1.8/gems/rubyosa-0.2.0/lib/rbosa.rb:201: > [BUG] Bus Error > ruby 1.8.5 (2006-12-25) [i686-darwin8.8.1] > > All I need to do is to start an applescript from ruby along with some > strings. Can this be done with RubyOSA? > > _______________________________________________ > Rubyosa-discuss mailing list > Rubyosa-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/rubyosa-discuss From lsansonetti at apple.com Wed Feb 28 18:15:48 2007 From: lsansonetti at apple.com (Laurent Sansonetti) Date: Thu, 1 Mar 2007 00:15:48 +0100 Subject: [Rubyosa-discuss] sdef merging, API changes In-Reply-To: References: <14148D8B-9954-40F2-B1B4-99ECEF7E12C0@apple.com> Message-ID: <9B02CA59-841F-40F2-B239-32B78B392475@apple.com> Hi Ale, Thanks for the feedback. Actually I found that the merge support wasn't working 100% of the time. I fixed the SVN repository, could you try again? The following snippet works on my environment: app = OSA.app('iTunes') app.merge('StandardAdditions') app.beep(10) p app.choose_file Laurent On Feb 27, 2007, at 12:46 PM, Ale Mu?oz wrote: > On 1/30/07, Laurent Sansonetti wrote: >> >> It's now possible to merge a given scriptable definition into the >> current application object. A #merge method has been added for this. >> Example: >> >> ichat = OSA.app('iChat') >> ichat.merge(:by_path => '/System/Library/ScriptingAdditions/ >> StandardAdditions.osax') >> ichat.beep(4) # will beep 4 times >> >> #merge also accepts :by_name, :by_bundle_id and :by_signature key/ >> values. >> > > > Hi there, > > could you please provide some more examples of merge? > > I'm trying to get it working with the latest SVN checkout but so far > it does nothing :( > > Here's my code: > > begin require 'rubygems'; rescue LoadError; end > require 'rbosa' > > app = OSA.app('iTunes') > OSA.utf8_strings = true > app.merge(:path => '/System/Library/ScriptingAdditions/ > StandardAdditions.osax') > app.beep(4) > > And it provides me with a nice and clean nothing, neither beep, nor > error :) > > Thanks in advance! > > > -- > Ale Mu?oz > http://sofanaranja.com > http://bomberstudios.com > _______________________________________________ > Rubyosa-discuss mailing list > Rubyosa-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/rubyosa-discuss From bomberstudios at gmail.com Wed Feb 28 18:42:49 2007 From: bomberstudios at gmail.com (=?UTF-8?Q?Ale_Mu=C3=B1oz?=) Date: Thu, 1 Mar 2007 00:42:49 +0100 Subject: [Rubyosa-discuss] sdef merging, API changes In-Reply-To: <9B02CA59-841F-40F2-B239-32B78B392475@apple.com> References: <14148D8B-9954-40F2-B1B4-99ECEF7E12C0@apple.com> <9B02CA59-841F-40F2-B239-32B78B392475@apple.com> Message-ID: On 3/1/07, Laurent Sansonetti wrote: > Hi Ale, > > Thanks for the feedback. Thanks to you for your wonderful work :) > Actually I found that the merge support > wasn't working 100% of the time. I fixed the SVN repository, could you > try again? > > The following snippet works on my environment: > > app = OSA.app('iTunes') > app.merge('StandardAdditions') > app.beep(10) > p app.choose_file > I just updated my checkout, and it works like a charm. I had to restart because iTunes crashed deadly (even kill -9 wouldn't kill it) but it's working beautifully now, so I can only asume it was my MacBook playing tricks on me :) Just one thing... beep(10) actually beeps 11 times. Try beep(0) and see what I mean :) All in all, merge support will make my life so much easier. I have some pretty convoluted AppleScripts that are just *begging* to be translated to Ruby, and they use (of course) StandardAdditions :) Looks like a busy weekend is coming... Thank you very very very much, Laurent. -- Ale Mu?oz http://sofanaranja.com http://bomberstudios.com