From tomtoday at gmail.com Thu Oct 26 00:05:15 2006 From: tomtoday at gmail.com (Tom Brice) Date: Wed, 25 Oct 2006 23:05:15 -0500 Subject: [Rubyosa-discuss] File handling Message-ID: <8A0BDBD6-A9C9-4FF0-B92A-89B9CABFD713@gmail.com> First, thanks for offering this up to the community. It's pretty exciting to have an alternative to Applescript via Ruby. I have a question regarding access to files. In Applescript I typically access files with something like this: set myFile to alias "path:to:my:file" I'm particularly interested in operating on POSIX type paths (since that's what I'll get from something line Dir.glob()). I cannot figure out how to do this with rubyosa. I went to the samples (specifically QT_playall.rb) to see how it was done but I cannot get that script to work. Here's what I tried: tbrice at tom:~/Desktop/sample movies % ls -al drwxr-xr-x 14 tbrice tbrice 476 Oct 25 20:43 ./ drwx------ 49 tbrice tbrice 1666 Oct 25 17:14 ../ -rw-r--r-- 1 tbrice tbrice 12292 Oct 8 14:25 .DS_Store -rw-r--r-- 1 tbrice tbrice 107838630 Oct 6 18:15 sample_movie.mov tbrice at tom:~/Desktop/sample movies % ruby /Users/tbrice/src/rubyosa/ trunk/sample/QT_playall.rb /Users/tbrice/Desktop/sample\ movies/ caroline_20061018.mov (eval):2:in `__send_event__': Cannot send Apple Event 'aevtodoc' : procNotFound (-600) (RuntimeError) from (eval):2:in `open' from /Users/tbrice/src/rubyosa/trunk/sample/QT_playall.rb:11 from /Users/tbrice/src/rubyosa/trunk/sample/QT_playall.rb:11 I'm not sure what to supply to, for example, OSA.app('QuickTime Player').open(arg) as an argument. Seems that a POSIX file path does not work. Since the sample is expecting a command line arg I'm assuming it's not a ruby File object. Can you point me in the right direction? Thanks in advance Tom From lsansonetti at apple.com Thu Oct 26 16:37:09 2006 From: lsansonetti at apple.com (Laurent Sansonetti) Date: Thu, 26 Oct 2006 22:37:09 +0200 Subject: [Rubyosa-discuss] File handling In-Reply-To: <8A0BDBD6-A9C9-4FF0-B92A-89B9CABFD713@gmail.com> References: <8A0BDBD6-A9C9-4FF0-B92A-89B9CABFD713@gmail.com> Message-ID: Hi Tom, On Oct 26, 2006, at 6:05 AM, Tom Brice wrote: > First, thanks for offering this up to the community. It's pretty > exciting to have an alternative to Applescript via Ruby. > Thank you, I'm glad you enjoy the project. > I have a question regarding access to files. In Applescript I > typically access files with something like this: > > set myFile to alias "path:to:my:file" > > I'm particularly interested in operating on POSIX type paths (since > that's what I'll get from something line Dir.glob()). > > I cannot figure out how to do this with rubyosa. I went to the > samples (specifically QT_playall.rb) to see how it was done but I > cannot get that script to work. Here's what I tried: > > tbrice at tom:~/Desktop/sample movies % ls -al > drwxr-xr-x 14 tbrice tbrice 476 Oct 25 20:43 ./ > drwx------ 49 tbrice tbrice 1666 Oct 25 17:14 ../ > -rw-r--r-- 1 tbrice tbrice 12292 Oct 8 14:25 .DS_Store > -rw-r--r-- 1 tbrice tbrice 107838630 Oct 6 18:15 > sample_movie.mov > tbrice at tom:~/Desktop/sample movies % ruby /Users/tbrice/src/rubyosa/ > trunk/sample/QT_playall.rb /Users/tbrice/Desktop/sample\ movies/ > caroline_20061018.mov > (eval):2:in `__send_event__': Cannot send Apple Event 'aevtodoc' : > procNotFound (-600) (RuntimeError) > from (eval):2:in `open' > from /Users/tbrice/src/rubyosa/trunk/sample/QT_playall.rb:11 > from /Users/tbrice/src/rubyosa/trunk/sample/QT_playall.rb:11 > > > I'm not sure what to supply to, for example, > OSA.app('QuickTime Player').open(arg) > as an argument. Seems that a POSIX file path does not work. Since > the sample is expecting a command line arg I'm assuming it's not a > ruby File object. > > Can you point me in the right direction? > This QT_playall.rb sample works fine on my machine. However I noticed that the QuickTime Player application should be running first, otherwise I always get the same message than you. I thought this was because I'm running a version of Mac OS X that is still under development, but since you have this problem on a stable version (I guess at least) I will investigate this more . At a glance RubyOSA is not problematic there. You can try on another application like TextEdit that doesn't seem to have this problem. For example: $ ruby -r rbosa -e "OSA.app('TextEdit').open(ARGV.first)" In order to know more about the RubyOSA API for a given application, you can use the rdoc-osa command line tool that comes with version 0.1.0. Usage is simple: $ rdoc-osa --name "QuickTime Player" $ open doc/index.html HTH, Laurent From lists at kalama.no-ip.org Thu Oct 26 19:31:49 2006 From: lists at kalama.no-ip.org (lists) Date: Thu, 26 Oct 2006 18:31:49 -0500 Subject: [Rubyosa-discuss] displaying dialogs Message-ID: Hi, is anyone familiar with a way to display interactive dialogs windows in the Finder using rbosa? Here's the AppleScript equivalent of what I'm trying to do: tell application "System Events" to display dialog "Hi there" Thanks From jeanpierre at gmail.com Thu Oct 26 21:32:04 2006 From: jeanpierre at gmail.com (jeanpierre at gmail.com) Date: Thu, 26 Oct 2006 18:32:04 -0700 Subject: [Rubyosa-discuss] displaying dialogs In-Reply-To: References: Message-ID: On 10/26/06, lists wrote: > Hi, is anyone familiar with a way to display interactive dialogs > windows in the Finder using rbosa? Here's the AppleScript equivalent > of what I'm trying to do: > > tell application "System Events" to display dialog "Hi there" you might try generating the documentation for system events to see how this can be done: % rdoc-osa --name 'System Events' if you didn't install via gem, check the bin directory in the source. cheers, jean-pierre From jmacaulay at gmail.com Thu Oct 26 21:46:47 2006 From: jmacaulay at gmail.com (James MacAulay) Date: Thu, 26 Oct 2006 21:46:47 -0400 Subject: [Rubyosa-discuss] displaying dialogs In-Reply-To: References: Message-ID: I don't know, but here's my two cents: After poking around a bit, it looks like 'display dialog' isn't attached to any particular application; i.e. you can tell any application to 'display dialog' and it will do the same thing (and actually, it seems to work faster if you just drop the 'tell application' bit so that it uses the current application and doesn't have to switch). It's included in a scripting addition package called StandardAdditions in the scripting dictionary in script editor, but I don't know if/how this package can be accessed with rubyosa. Maybe the same result could be achieved using a different route, also. James On 26-Oct-06, at 7:31 PM | Oct 26, lists wrote: > Hi, is anyone familiar with a way to display interactive dialogs > windows in the Finder using rbosa? Here's the AppleScript equivalent > of what I'm trying to do: > > tell application "System Events" to display dialog "Hi there" > > Thanks > _______________________________________________ > Rubyosa-discuss mailing list > Rubyosa-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/rubyosa-discuss From jmacaulay at gmail.com Thu Oct 26 21:53:46 2006 From: jmacaulay at gmail.com (James MacAulay) Date: Thu, 26 Oct 2006 21:53:46 -0400 Subject: [Rubyosa-discuss] 0.1.0 Message-ID: I just wanted to say a public congratulations and thank you to Laurent for all his work on bringing RubyOSA to this point. Also, I wanted to point out this post on rubyosa for those who haven't seen it: http://www.tuaw.com/2006/10/26/ruby-applescript-rubyosa/ James From rangerrick at gmail.com Thu Oct 26 21:55:11 2006 From: rangerrick at gmail.com (Benjamin Reed) Date: Thu, 26 Oct 2006 21:55:11 -0400 Subject: [Rubyosa-discuss] rubyosa in fink Message-ID: <57eba2250610261855g1f21d380s401330cd1218e502@mail.gmail.com> FYI, I've made Fink packages for rubyosa (and libxml-ruby), they're available in unstable for 10.3 and 10.4. Awesome tool, guys, thanks! From lists at kalama.no-ip.org Thu Oct 26 22:05:15 2006 From: lists at kalama.no-ip.org (lists) Date: Thu, 26 Oct 2006 21:05:15 -0500 Subject: [Rubyosa-discuss] displaying dialogs In-Reply-To: References: Message-ID: On Oct 26, 2006, at 8:32 PM, jeanpierre at gmail.com wrote: > On 10/26/06, lists wrote: >> Hi, is anyone familiar with a way to display interactive dialogs >> windows in the Finder using rbosa? Here's the AppleScript equivalent >> of what I'm trying to do: >> >> tell application "System Events" to display dialog "Hi there" > > you might try generating the documentation for system events to see > how this can be done: > % rdoc-osa --name 'System Events' > > if you didn't install via gem, check the bin directory in the source. > > cheers, > jean-pierre > Hi, I actually already tried that and got nothing. Maybe I'm just being dense. Thanks anyway though. -Ryan From tomtoday at gmail.com Thu Oct 26 22:18:13 2006 From: tomtoday at gmail.com (Tom Brice) Date: Thu, 26 Oct 2006 21:18:13 -0500 Subject: [Rubyosa-discuss] displaying dialogs In-Reply-To: References: Message-ID: On Oct 26, 2006, at 8:32 PM, jeanpierre at gmail.com wrote: > On 10/26/06, lists wrote: >> Hi, is anyone familiar with a way to display interactive dialogs >> windows in the Finder using rbosa? Here's the AppleScript equivalent >> of what I'm trying to do: >> >> tell application "System Events" to display dialog "Hi there" > > you might try generating the documentation for system events to see > how this can be done: > % rdoc-osa --name 'System Events' > > if you didn't install via gem, check the bin directory in the source. Unfortunately 'display dialog' is provided by and OSAX (StandardAdditions.osax, provided with the OS). % rdoc-osa --name 'StandardAdditions.osax' does not work so I appears that rubyosa cannot access OSAX. I'm not sure how one could get Applescript's user interaction stuff here. Perhaps utilizing RubyCocoa will get you there. And it you get there, let us know ;) From jeanpierre at gmail.com Thu Oct 26 23:45:55 2006 From: jeanpierre at gmail.com (jeanpierre at gmail.com) Date: Thu, 26 Oct 2006 20:45:55 -0700 Subject: [Rubyosa-discuss] displaying dialogs In-Reply-To: References: Message-ID: On 10/26/06, Tom Brice wrote: [?] > Unfortunately 'display dialog' is provided by and OSAX > (StandardAdditions.osax, provided with the OS). > > % rdoc-osa --name 'StandardAdditions.osax' > > does not work so I appears that rubyosa cannot access OSAX. StandardAdditions.osax isn't an application so i'm not sure how that would work - you don't want to script it, you want to use the scripting extensions it defines. the above command probably wouldn't work anyways since launch services probably doesn't know it by name but if you specify the full path, it doesn't go over well. cheers, jean-pierre From lists at kalama.no-ip.org Fri Oct 27 00:20:36 2006 From: lists at kalama.no-ip.org (lists) Date: Thu, 26 Oct 2006 23:20:36 -0500 Subject: [Rubyosa-discuss] displaying dialogs In-Reply-To: References: Message-ID: On Oct 26, 2006, at 9:18 PM, Tom Brice wrote: > Unfortunately 'display dialog' is provided by and OSAX > (StandardAdditions.osax, provided with the OS). > > % rdoc-osa --name 'StandardAdditions.osax' > > does not work so I appears that rubyosa cannot access OSAX. I'm not > sure how one could get Applescript's user interaction stuff here. > Perhaps utilizing RubyCocoa will get you there. And it you get > there, let us know ;) Hmm, I was just looking at the usage of NSAlert at . Maybe it's doable that way. -Ryan From jeanpierre at gmail.com Fri Oct 27 01:33:54 2006 From: jeanpierre at gmail.com (jeanpierre at gmail.com) Date: Thu, 26 Oct 2006 22:33:54 -0700 Subject: [Rubyosa-discuss] displaying dialogs In-Reply-To: References: Message-ID: On 10/26/06, lists wrote: > On Oct 26, 2006, at 9:18 PM, Tom Brice wrote: [?] > > Perhaps utilizing RubyCocoa will get you there. And it you get > > there, let us know ;) > > Hmm, I was just looking at the usage of NSAlert at www.oreillynet.com/pub/a/mac/2004/10/12/cocoa.html?page=2>. Maybe > it's doable that way. along those lines, the code below displays an alert and might give others a kick start into their own explorations. i couldn't find the constants defined by NSPanel and instead hard coded them. the focus is a little strange since the application is running from within the terminal, so much for a modal dialogue... cheers, jean-pierre ############### #!/usr/bin/env ruby require "osx/cocoa" # guts taken from /Developer/RubyCocoa/TransparentHello.rb if __FILE__ == $0 # # First, to establish a connection to the window server, # we must initialize the application # $stderr.print "just wait ...\n" ; $stderr.flush application = OSX::NSApplication.sharedApplication # create the alert alert = OSX::NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat('message', 'default', 'alternate', 'other', '') # show it retval = alert.runModal # determine which button was pressed case retval when 1 #NSAlertDefaultReturn $stderr.puts 'default' when 0 #NSAlertAlternateReturn $stderr.puts 'alternate' when -1 #NSAlertOtherReturn $stderr.puts 'other' when -2 #NSAlertErrorReturn $stderr.puts 'error return' else $stderr.puts '*** invalid return value' end # And start the application event loop $stderr.print "\rtype `Ctrl-C' for quit !\n" trap('SIGINT') { $stderr.puts "bye." ; exit 0 } application.run end ############### From lists at kalama.no-ip.org Fri Oct 27 07:38:39 2006 From: lists at kalama.no-ip.org (lists) Date: Fri, 27 Oct 2006 06:38:39 -0500 Subject: [Rubyosa-discuss] displaying dialogs In-Reply-To: References: Message-ID: <186F3D4A-234D-4F72-828E-1A6382939F4E@kalama.no-ip.org> On Oct 27, 2006, at 12:33 AM, jeanpierre at gmail.com wrote: > along those lines, the code below displays an alert and might give > others a kick start into their own explorations. i couldn't find the > constants defined by NSPanel and instead hard coded them. the focus is > a little strange since the application is running from within the > terminal, so much for a modal dialogue... > > cheers, > jean-pierre Thanks, that was just what I was looking for! -Ryan From tomtoday at gmail.com Fri Oct 27 11:52:53 2006 From: tomtoday at gmail.com (Tom Brice) Date: Fri, 27 Oct 2006 10:52:53 -0500 Subject: [Rubyosa-discuss] File handling In-Reply-To: References: <8A0BDBD6-A9C9-4FF0-B92A-89B9CABFD713@gmail.com> Message-ID: <69FEE38A-272B-4CCA-BBA1-20ABFB295DE1@gmail.com> On Oct 26, 2006, at 3:37 PM, Laurent Sansonetti wrote: > This QT_playall.rb sample works fine on my machine. However I > noticed that the QuickTime Player application should be running > first, otherwise I always get the same message than you. I > thought this was because I'm running a version of Mac OS X that is > still under development, but since you have this problem on a > stable version (I guess at least) I will investigate this more . At > a glance RubyOSA is not problematic there. > If QuickTime Player is running it works. I feel dumb. And Yes, I'm using OS X 10.4.8 (Intel) > You can try on another application like TextEdit that doesn't seem > to have this problem. For example: > > $ ruby -r rbosa -e "OSA.app('TextEdit').open(ARGV.first)" your-text-file> That does not work because I've installed using rubygems (side note: you may want to update your sample code to take into account rubygems installs as this may be a major stumbling block to newbies). Strangely this does not either: $ ruby -r rubygems -r rbosa -e "OSA.app('TextEdit').open(ARGV.first)" '/path/to/test.txt' # ruby: no such file to load -- rbosa (LoadError) I can do it in irb however: $ irb -r rubygems -r rbosa >> OSA.app('TextEdit').open('/path/to/test.txt') => nil And it works even when TextEdit is not running. I tried for a few minutes to see how to launch apps that are not running but was unsuccessful. I'll bang on it a little more today. > > HTH, > Laurent Yes, very much. Thanks Tom From hornbeck at gmail.com Tue Oct 24 10:30:37 2006 From: hornbeck at gmail.com (John Hornbeck) Date: Tue, 24 Oct 2006 09:30:37 -0500 Subject: [Rubyosa-discuss] Kumbaya = RubyOSA + iTunes + Marshmallow Message-ID: <6340ac5f0610240730j28417e25he2983a00c07bf0f3@mail.gmail.com> Hello, I wanted to share a little hack that my team put together yesterday. If you use OS X, Campfire and Itunes check it out. Kumbaya = RubyOSA + iTunes + Marshmallow http://www.42squared.com/2006/10/24/kumbaya-rubyosa-chatbot-for-campfire/ Yesterday we combined three of our favorite things: RubyOSA, iTunes, and Marshmallow (the chatbot for Campfire). Enter Kumbaya. Kumbaya is a modified Marshmallow bot that polls your iTunes with RubyOSA (on Mac OS X) and broadcasts the name and artist of the song currently playing into a Campfire chat room. We released the source and invite you to check it out, modify it, and use it freely. 42squared, LLC http://www.42squared.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rubyosa-discuss/attachments/20061024/336e9845/attachment.html From lrz at chopine.be Fri Oct 27 11:36:07 2006 From: lrz at chopine.be (Laurent Sansonetti) Date: Fri, 27 Oct 2006 17:36:07 +0200 Subject: [Rubyosa-discuss] BUS error while `irb -r rbosa' + troubleshooting page Message-ID: <910D4A51-FE73-4528-B41E-1E3877A852F6@chopine.be> Hi, Some people reported a BUS error crash when doing `irb -r rbosa'. After a quick investigation is appears that this problem is a bug in 1.8.4, and that it has been fixed in 1.8.5. Also, I wrote a small page to describe this problem along with the libxml_so issue: http://rubyosa.rubyforge.org/troubles.html Laurent From jmacaulay at gmail.com Sat Oct 28 16:25:42 2006 From: jmacaulay at gmail.com (James MacAulay) Date: Sat, 28 Oct 2006 16:25:42 -0400 Subject: [Rubyosa-discuss] BUS error while `irb -r rbosa' + troubleshooting page In-Reply-To: <910D4A51-FE73-4528-B41E-1E3877A852F6@chopine.be> References: <910D4A51-FE73-4528-B41E-1E3877A852F6@chopine.be> Message-ID: <891D503E-45CE-4AFA-BDD6-51C0B55A9AA9@gmail.com> Also, I don't think libxml works with any ruby before 1.8.3 or 1.8.4 (at least on OSX), so that's another reason for people not to use the prepackaged OSX ruby binaries that are out there which are still built from 1.8.2. James On 27-Oct-06, at 11:36 AM | Oct 27, Laurent Sansonetti wrote: > Hi, > > Some people reported a BUS error crash when doing `irb -r rbosa'. > After a quick investigation is appears that this problem is a bug in > 1.8.4, and that it has been fixed in 1.8.5. > > Also, I wrote a small page to describe this problem along with the > libxml_so issue: > > http://rubyosa.rubyforge.org/troubles.html > > Laurent > _______________________________________________ > Rubyosa-discuss mailing list > Rubyosa-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/rubyosa-discuss From lrz at chopine.be Sat Oct 28 17:37:25 2006 From: lrz at chopine.be (Laurent Sansonetti) Date: Sat, 28 Oct 2006 23:37:25 +0200 Subject: [Rubyosa-discuss] File handling In-Reply-To: <69FEE38A-272B-4CCA-BBA1-20ABFB295DE1@gmail.com> References: <8A0BDBD6-A9C9-4FF0-B92A-89B9CABFD713@gmail.com> <69FEE38A-272B-4CCA-BBA1-20ABFB295DE1@gmail.com> Message-ID: <3FD4580D-114D-4833-9889-CFB5CB75ADAE@chopine.be> Hi Tom, On Oct 27, 2006, at 5:52 PM, Tom Brice wrote: > On Oct 26, 2006, at 3:37 PM, Laurent Sansonetti wrote: > >> This QT_playall.rb sample works fine on my machine. However I >> noticed that the QuickTime Player application should be running >> first, otherwise I always get the same message than you. I >> thought this was because I'm running a version of Mac OS X that is >> still under development, but since you have this problem on a >> stable version (I guess at least) I will investigate this more . At >> a glance RubyOSA is not problematic there. >> > If QuickTime Player is running it works. I feel dumb. And Yes, I'm > using OS X 10.4.8 (Intel) > No worries, I find this very confusing too, and we are certainly not alone :) After a quick investigation it revealed that QuickTime Player.app doesn't wake up when we request its scriptable definition, for the reason that it uses the old aete mechanism and that the sdef is generated on the fly, without the need to actually start and ask the application. However from a RubyOSA perspective, we should probably ensure that the given application is active after an OSA.app call. >> You can try on another application like TextEdit that doesn't seem >> to have this problem. For example: >> >> $ ruby -r rbosa -e "OSA.app('TextEdit').open(ARGV.first)" > your-text-file> > > That does not work because I've installed using rubygems (side note: > you may want to update your sample code to take into account > rubygems installs as this may be a major stumbling block to newbies). The samples have been converted to require rubygems if necessary. > Strangely this does not either: > > $ ruby -r rubygems -r rbosa -e > "OSA.app('TextEdit').open(ARGV.first)" '/path/to/test.txt' > # ruby: no such file to load -- rbosa (LoadError) > True, I also noticed that this doesn't work. I wonder why :) Laurent From lrz at chopine.be Sat Oct 28 17:32:24 2006 From: lrz at chopine.be (Laurent Sansonetti) Date: Sat, 28 Oct 2006 23:32:24 +0200 Subject: [Rubyosa-discuss] rubyosa in fink In-Reply-To: <57eba2250610261855g1f21d380s401330cd1218e502@mail.gmail.com> References: <57eba2250610261855g1f21d380s401330cd1218e502@mail.gmail.com> Message-ID: Hi Benjamin, On Oct 27, 2006, at 3:55 AM, Benjamin Reed wrote: > FYI, I've made Fink packages for rubyosa (and libxml-ruby), they're > available in unstable for 10.3 and 10.4. > > Awesome tool, guys, thanks! Wow that's great, I just mentioned it in the homepage. Thanks! Laurent From jeanpierre at gmail.com Sun Oct 29 15:34:22 2006 From: jeanpierre at gmail.com (jeanpierre at gmail.com) Date: Sun, 29 Oct 2006 13:34:22 -0700 Subject: [Rubyosa-discuss] Finder scripting Message-ID: i just cannot seem to wrap my head around using rubyosa to interact with the finder. i generated the lovely rdoc doumentation and read through it, but i am failing to understand how i would reference an arbitrary folder or file. say i want to move some file matz.png from /tmp to the user's documents folder... all i can come up with so far is: finder = OSA.app('Finder') file = '?' # somehow reference /tmp/matz.png documents = finder.home.items.select {|i| i.name == 'Documents'} file.move(documents) there must be a better way than selecting items right? also, how does one do anything with a selection? OSA.app('Finder').selection returns an OSA::Element instance that doesn't seem to offer up any way to pull the actual items out. any ideas? cheers, jean-pierre From lrz at chopine.be Sun Oct 29 16:58:52 2006 From: lrz at chopine.be (Laurent Sansonetti) Date: Sun, 29 Oct 2006 22:58:52 +0100 Subject: [Rubyosa-discuss] Finder scripting In-Reply-To: References: Message-ID: Hi Jean-Pierre, On Oct 29, 2006, at 9:34 PM, jeanpierre at gmail.com wrote: > i just cannot seem to wrap my head around using rubyosa to interact > with the finder. i generated the lovely rdoc doumentation and read > through it, but i am failing to understand how i would reference an > arbitrary folder or file. > > say i want to move some file matz.png from /tmp to the user's > documents folder... > > all i can come up with so far is: > finder = OSA.app('Finder') > file = '?' # somehow reference /tmp/matz.png > documents = finder.home.items.select {|i| i.name == 'Documents'} > file.move(documents) > > there must be a better way than selecting items right? > I plan to enhance the API to make this kind of requests easier. > also, how does one do anything with a selection? > OSA.app('Finder').selection returns an OSA::Element instance that > doesn't seem to offer up any way to pull the actual items out. > The problem is that most of the API defined in the Finder's sdef is not typed (e.g. it uses the 'reference' type which means 'any class defined in the sdef'). So RubyOSA can't appropriately type the variables by default without actually sending an event, which we don't by default, for performances reasons. So, by default, RubyOSA doesn't send an event if you do #selection. You can control this behavior with the OSA.lazy_events variable. For example: $ irb -r rbosa >> OSA.lazy_events => true >> a = OSA.app('Finder') => # >> a.selection => # You can set lazy_events to false, then RubyOSA will send an apple event message within each method. >> OSA.lazy_events = false => false >> a.selection => [#] When lazy_events is true, you can still explicitly resolve an object specifier using the #get method. >> OSA.lazy_events = true => true >> a.selection => # >> a.selection.get => [#] This remains me that I should document this... ! HTH, Laurent PS: On a side note, there is another global parameter, `timeout', that controls the timeout of responses when sending apple events. By default we use the default timeout value which is a minute I believe, but you might want to set it to another value. And there is an extra API to manage global parameters in a more- convenient way: OSA.set_params(:timeout => 20, :lazy_events => false) do # Do some RubyOSA calls there end The parameters are set to given values within the life on the given block, then they are reset to the previous values. I will make sure these are documented for the next release :-) From lpruszynski at gmail.com Sun Oct 29 12:55:33 2006 From: lpruszynski at gmail.com (Les Pruszynski) Date: Sun, 29 Oct 2006 17:55:33 +0000 Subject: [Rubyosa-discuss] Running the Examples Message-ID: <96391668-A210-4712-AF49-FEE7BCE499F5@gmail.com> Hello and thanks for releasing RubyOSA to the public. I am convinced that it will revolutionalise the way we script MacOSX. However, I have a very simple question. How do I run the example scripts from the rubyosa-0.1.0. I've tried for example - ruby TextEdit_hello_world.rb from the command line but I get No such file or directory -- xxx.rb (LoadError) Many thanks, Les -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rubyosa-discuss/attachments/20061029/838872e1/attachment.html From jeanpierre at gmail.com Sun Oct 29 18:37:32 2006 From: jeanpierre at gmail.com (jeanpierre at gmail.com) Date: Sun, 29 Oct 2006 16:37:32 -0700 Subject: [Rubyosa-discuss] Finder scripting In-Reply-To: References: Message-ID: On 10/29/06, Laurent Sansonetti wrote: > Hi Jean-Pierre, > > On Oct 29, 2006, at 9:34 PM, jeanpierre at gmail.com wrote: > > > i just cannot seem to wrap my head around using rubyosa to interact > > with the finder. i generated the lovely rdoc doumentation and read > > through it, but i am failing to understand how i would reference an > > arbitrary folder or file. > > > > say i want to move some file matz.png from /tmp to the user's > > documents folder... > > > > all i can come up with so far is: > > finder = OSA.app('Finder') > > file = '?' # somehow reference /tmp/matz.png > > documents = finder.home.items.select {|i| i.name == 'Documents'} > > file.move(documents) > > > > there must be a better way than selecting items right? > > > > I plan to enhance the API to make this kind of requests easier. i think a set of general file utilities could be really helpful. in the interim, i'll wrap wrap calls to #items to make this a bit easier. i haven't done much with applescript in the past so perhaps its file reference abilities are pretty limited in this regard? > > also, how does one do anything with a selection? > > OSA.app('Finder').selection returns an OSA::Element instance that > > doesn't seem to offer up any way to pull the actual items out. > > > > The problem is that most of the API defined in the Finder's sdef is > not typed (e.g. it uses the 'reference' type which means 'any class > defined in the sdef'). So RubyOSA can't appropriately type the > variables by default without actually sending an event, which we don't > by default, for performances reasons. > > So, by default, RubyOSA doesn't send an event if you do #selection. > You can control this behavior with the OSA.lazy_events variable. For > example: > > $ irb -r rbosa > >> OSA.lazy_events > => true > >> a = OSA.app('Finder') > => # > >> a.selection > => # > > You can set lazy_events to false, then RubyOSA will send an apple > event message within each method. > > >> OSA.lazy_events = false > => false > >> a.selection > => [#] > > When lazy_events is true, you can still explicitly resolve an object > specifier using the #get method. > > >> OSA.lazy_events = true > => true > >> a.selection > => # > >> a.selection.get > => [#] ahh excellent, this really helps me along. does OSA::Element#get just send an event to resolve the type or perhaps better said - when would it be advantageous to set lazy_events to false during execution rather than using get to resolve on demand? repeated calls perhaps? thanks for your help and clarification! cheers, jean-pierre From jeanpierre at gmail.com Sun Oct 29 23:29:41 2006 From: jeanpierre at gmail.com (jeanpierre at gmail.com) Date: Sun, 29 Oct 2006 21:29:41 -0700 Subject: [Rubyosa-discuss] Running the Examples In-Reply-To: <96391668-A210-4712-AF49-FEE7BCE499F5@gmail.com> References: <96391668-A210-4712-AF49-FEE7BCE499F5@gmail.com> Message-ID: On 10/29/06, Les Pruszynski wrote: > Hello and thanks for releasing RubyOSA to the public. I am convinced that it > will revolutionalise the way we script MacOSX. > However, I have a very simple question. How do I run the example scripts > from the rubyosa-0.1.0. > I've tried for example - ruby TextEdit_hello_world.rb from the command line > but I get > No such file or directory -- xxx.rb (LoadError) strange that exactly how you'd run the samples. perhaps this is a ridiculous question, but have you installed libxml-ruby and rubyosa first? cheers, jean-pierre From jeanpierre at gmail.com Mon Oct 30 00:11:58 2006 From: jeanpierre at gmail.com (jeanpierre at gmail.com) Date: Sun, 29 Oct 2006 22:11:58 -0700 Subject: [Rubyosa-discuss] Running the Examples In-Reply-To: <9016E2CA-85FF-4255-99B1-DF79820FEE01@gmail.com> References: <96391668-A210-4712-AF49-FEE7BCE499F5@gmail.com> <9016E2CA-85FF-4255-99B1-DF79820FEE01@gmail.com> Message-ID: On 10/29/06, Les Pruszynski wrote: > Hi Jean-Pierre, > Yes I have installed it through ruby gems. > I can do some tinkering through the irb and that works: > > $ irb -r rubygems -r rbosa > irb(main):001:0> > > but I am unable to run the examples from my shell > > $ ruby .../Desktop/rubyosa-0.1.0/sample/iTunes_inspect.rb > .../Desktop/rubyosa-0.1.0/sample/iTunes_inspect.rb:3:in `require': no > such file to load -- rbosa (LoadError) > from .../Desktop/rubyosa-0.1.0/sample/iTunes_inspect.rb:3 > > It looks as if ruby is unable to find rbosa. > Maybe the example scripts should be modified to account for the fact > that rbosa was installed via rubygems. > I'm not sure. good detective work, that is exactly it - the samples were not first trying to require rubygems before rubyosa - and was fixed on friday =) to get the updated samples, you can pull the rubyosa subversion trunk down[1] directly download the samples[2] or just add the following line in each of the samples before the rubyosa require. begin require 'rubygems' rescue LoadError end cheers, jean-pierre [1] http://rubyforge.org/scm/?group_id=1845 [2] http://rubyforge.org/cgi-bin/viewvc.cgi/trunk/sample/?root=rubyosa From lrz at chopine.be Mon Oct 30 07:26:29 2006 From: lrz at chopine.be (Laurent Sansonetti) Date: Mon, 30 Oct 2006 13:26:29 +0100 Subject: [Rubyosa-discuss] Finder scripting In-Reply-To: References: Message-ID: On Oct 30, 2006, at 12:37 AM, jeanpierre at gmail.com wrote: > On 10/29/06, Laurent Sansonetti wrote: >> Hi Jean-Pierre, >> >> On Oct 29, 2006, at 9:34 PM, jeanpierre at gmail.com wrote: >> >> > i just cannot seem to wrap my head around using rubyosa to interact >> > with the finder. i generated the lovely rdoc doumentation and read >> > through it, but i am failing to understand how i would reference an >> > arbitrary folder or file. >> > >> > say i want to move some file matz.png from /tmp to the user's >> > documents folder... >> > >> > all i can come up with so far is: >> > finder = OSA.app('Finder') >> > file = '?' # somehow reference /tmp/matz.png >> > documents = finder.home.items.select {|i| i.name == >> 'Documents'} >> > file.move(documents) >> > >> > there must be a better way than selecting items right? >> > >> >> I plan to enhance the API to make this kind of requests easier. > > i think a set of general file utilities could be really helpful. in > the interim, i'll wrap wrap calls to #items to make this a bit easier. > i haven't done much with applescript in the past so perhaps its file > reference abilities are pretty limited in this regard? > >> > also, how does one do anything with a selection? >> > OSA.app('Finder').selection returns an OSA::Element instance that >> > doesn't seem to offer up any way to pull the actual items out. >> > >> >> The problem is that most of the API defined in the Finder's sdef is >> not typed (e.g. it uses the 'reference' type which means 'any class >> defined in the sdef'). So RubyOSA can't appropriately type the >> variables by default without actually sending an event, which we >> don't >> by default, for performances reasons. >> >> So, by default, RubyOSA doesn't send an event if you do #selection. >> You can control this behavior with the OSA.lazy_events variable. For >> example: >> >> $ irb -r rbosa >> >> OSA.lazy_events >> => true >> >> a = OSA.app('Finder') >> => # >> >> a.selection >> => # >> >> You can set lazy_events to false, then RubyOSA will send an apple >> event message within each method. >> >> >> OSA.lazy_events = false >> => false >> >> a.selection >> => [#] >> >> When lazy_events is true, you can still explicitly resolve an object >> specifier using the #get method. >> >> >> OSA.lazy_events = true >> => true >> >> a.selection >> => # >> >> a.selection.get >> => [#] > > ahh excellent, this really helps me along. does OSA::Element#get just > send an event to resolve the type or perhaps better said - when would > it be advantageous to set lazy_events to false during execution rather > than using get to resolve on demand? repeated calls perhaps? > Yeah, sometimes you might want to wrap several calls at once without using lazy events. Laurent From jeanpierre at gmail.com Mon Oct 30 13:49:25 2006 From: jeanpierre at gmail.com (jeanpierre at gmail.com) Date: Mon, 30 Oct 2006 11:49:25 -0700 Subject: [Rubyosa-discuss] Running the Examples In-Reply-To: <78F668F7-955D-464D-999D-2D88D479A610@gmail.com> References: <96391668-A210-4712-AF49-FEE7BCE499F5@gmail.com> <9016E2CA-85FF-4255-99B1-DF79820FEE01@gmail.com> <78F668F7-955D-464D-999D-2D88D479A610@gmail.com> Message-ID: On 10/30/06, Les Pruszynski wrote: > Hello Jean-Pierre, > Great, that what I needed. > However, I think that this line should be transparent to the ruby > scripter. > One shouldn't care what way rbosa was installed, vie rubygems or not. > rerquire 'rbosa' in the script should just work. > My 2c. > Les i've seen people edit their ~/.irbrc to include the rubygems require by default to prevent problems this sort and i would have to imagine that one could do that same thing using ~/.rubyrc.(?) i'm not sure if this could be solved at the ruby library level, it seems like a gem infrastructure / include path issue. cheers, jean-pierre From dustym at gmail.com Mon Oct 30 20:56:36 2006 From: dustym at gmail.com (Dusty Matthews) Date: Mon, 30 Oct 2006 19:56:36 -0600 Subject: [Rubyosa-discuss] Image Events Message-ID: <8641CBBE-30EE-4920-9F49-83AD6038316D@gmail.com> Has anyone tried using Image Events with RubyOSA? I can call OSA.app ('Image Events') and get all sorts of interesting stuff from that and rdoc-osa, but at the end of the day I can't figure out how to get an OSA::ImageEvents::Item that represents an existing image. For example, i = OSA.app('Image Events') i.open('some image') doesn't work because open is private. OSA::ImageEvents::Application#items returns a list of items associated with the app instance, but I don't know how to create or push those items into the instance in the first place. I think I might have a fundamental misunderstanding of how Image Events interacts with existing files? Thanks for the help. dusty From jeanpierre at gmail.com Mon Oct 30 21:36:04 2006 From: jeanpierre at gmail.com (jeanpierre at gmail.com) Date: Mon, 30 Oct 2006 18:36:04 -0800 Subject: [Rubyosa-discuss] Finder scripting In-Reply-To: References: Message-ID: On 10/29/06, jeanpierre at gmail.com wrote: > On 10/29/06, Laurent Sansonetti wrote: > > Hi Jean-Pierre, > > > > On Oct 29, 2006, at 9:34 PM, jeanpierre at gmail.com wrote: > > > > > i just cannot seem to wrap my head around using rubyosa to interact > > > with the finder. i generated the lovely rdoc doumentation and read > > > through it, but i am failing to understand how i would reference an > > > arbitrary folder or file. > > > > > > say i want to move some file matz.png from /tmp to the user's > > > documents folder... > > > > > > all i can come up with so far is: > > > finder = OSA.app('Finder') > > > file = '?' # somehow reference /tmp/matz.png > > > documents = finder.home.items.select {|i| i.name == 'Documents'} > > > file.move(documents) > > > > > > there must be a better way than selecting items right? > > > > > > > I plan to enhance the API to make this kind of requests easier. > > i think a set of general file utilities could be really helpful. in > the interim, i'll wrap wrap calls to #items to make this a bit easier. > i haven't done much with applescript in the past so perhaps its file > reference abilities are pretty limited in this regard? i've managed to figure out the (bizarre) applescript syntax necessary to pull this off: tell application "Finder" move alias "stable:private:tmp:matz.png" to folder "Documents" of home end tell now if i could only figure out how to do the following bit in rubyosa =) alias "stable:private:tmp:matz.png" cheers, jean-pierre From zpinter at zacharypinter.com Tue Oct 31 09:08:37 2006 From: zpinter at zacharypinter.com (Zachary Pinter) Date: Tue, 31 Oct 2006 08:08:37 -0600 Subject: [Rubyosa-discuss] OSA::Element of type alis Message-ID: Hi everybody, First off, thank you for this API. I've been experimenting with trying to get the file name of songs in my iTunes library (with the long term idea of accessing iTunes files and ratings over DRB). I've come up with the following: require 'rubygems' require_gem 'rubyosa' require 'rbosa' itunes = OSA.app('itunes') library = itunes.sources.find{|s| s.name == "Library"} library_playlist = library.library_playlists[0] file_track = library_playlist.file_tracks[0] puts file_track.location puts file_track.location.__type__ p file_track.location.__data__ Which produces: # alis "\000\000\000\000\001\274\000\002\000\000\fMacintosh HD\000\000\000 \000\000\000\000\000\000\000\000\000\000\000\000\276t\317-H+\000\000 \000\010,H\edisturbed - New Disease.mp3\000\000\000\000\000\000\000 \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000 \000\000\000\000\000\000\000\000\000\000\000\000\000\0100n\000\000\000 \000\000\000\000\000\000\000\000\000\377\377\377\377\000\000\t \000 \000\000\000\000\000\000\000\000\000\000\000\000\000\000\tDisturbed \000\000\020\000\010\000\000\276u#\215\000\000\000\021\000\010\000\000 \000\000\000\000\000\000\000\001\000\020\000\010,H\000\005\316\221\000 \005\316[\000\000j\242\000\002\000CMacintosh HD:Users:thez:Music:Disturbed:disturbed - New Disease.mp3\000\000\016 \0008\000\e\000d\000i\000s\000t\000u\000r\000b\000e\000d\000 \000- \000 \000N\000e\000w\000 \000D\000i\000s\000e\000a\000s\000e\000.\000m \000p\0003\000\017\000\032\000\f\000M\000a\000c\000i\000n\000t\000o \000s\000h\000 \000H\000D\000\022\0006Users/thez/Music/Disturbed/ disturbed - New Disease.mp3\000\023\000\001/\000\000\025\000\002\000\v \377\377\000\000" It looks like type 'alis' is not one of the data types that gets automatically converted to Ruby. Is there any chance of adding support for this? Perhaps converting it to a String or a Pathname object? Thanks! Zachary Pinter From tomtoday at gmail.com Tue Oct 31 11:41:26 2006 From: tomtoday at gmail.com (Tom Brice) Date: Tue, 31 Oct 2006 10:41:26 -0600 Subject: [Rubyosa-discuss] Image Events In-Reply-To: <8641CBBE-30EE-4920-9F49-83AD6038316D@gmail.com> References: <8641CBBE-30EE-4920-9F49-83AD6038316D@gmail.com> Message-ID: On Oct 30, 2006, at 7:56 PM, Dusty Matthews wrote: > Has anyone tried using Image Events with RubyOSA? I can call OSA.app > ('Image Events') and get all sorts of interesting stuff from that and > rdoc-osa, but at the end of the day I can't figure out how to get an > OSA::ImageEvents::Item that represents an existing image. > > For example, > > i = OSA.app('Image Events') > i.open('some image') > > doesn't work because open is private. > OSA::ImageEvents::Application#items returns a list of items > associated with the app instance, but I don't know how to create or > push those items into the instance in the first place. > > I think I might have a fundamental misunderstanding of how Image > Events interacts with existing files? > > Thanks for the help. > dusty Dusty, you might be interested in the fact that the commandline utility `sips`[1] does much of what ImageEvents can do so if you need a quick fix that might work for you. I also want to put in my $.02 here. I think file handles are the most opaque part of rubyosa right now. It appears that in some cases you can use an absolute path but not always (as evidenced above). Much of my Applescripting involves doing stuff with files: set aFile to "path:to:my:file" The analog to this in rubyosa needs to be clarified. Thanks in advance, Tom [1] http://www.hmug.org/man/1/sips.php From jmacaulay at gmail.com Tue Oct 31 12:05:16 2006 From: jmacaulay at gmail.com (James MacAulay) Date: Tue, 31 Oct 2006 12:05:16 -0500 Subject: [Rubyosa-discuss] OSA::Element of type alis In-Reply-To: References: Message-ID: Hi Zachary, I'm working on an iTunes project with RubyOSA as well, and this is how I deal with 'alis' objects: --- require 'rbosa' require 'uri' #(if necessary) # ... track = OSA.app_with_name('iTunes').sources[0].playlists[0].tracks[0] # (or whatever) pathname = URI.decode(URI.parse(track.location.__data__('furl')).path) # => "/Users/jmacaulay/Music/iTunes/iTunes Music/.../.../whatever.mp3" --- Then you can do File.new(pathname) or whatever you want in ruby. -James On 31-Oct-06, at 9:08 AM | Oct 31, Zachary Pinter wrote: > Hi everybody, > > First off, thank you for this API. I've been experimenting with > trying to get the file name of songs in my iTunes library (with the > long term idea of accessing iTunes files and ratings over DRB). I've > come up with the following: > > require 'rubygems' > require_gem 'rubyosa' > require 'rbosa' > > itunes = OSA.app('itunes') > > library = itunes.sources.find{|s| s.name == "Library"} > library_playlist = library.library_playlists[0] > > file_track = library_playlist.file_tracks[0] > > puts file_track.location > puts file_track.location.__type__ > p file_track.location.__data__ > > Which produces: > # > alis > "\000\000\000\000\001\274\000\002\000\000\fMacintosh HD\000\000\000 > \000\000\000\000\000\000\000\000\000\000\000\000\276t\317-H+\000\000 > \000\010,H\edisturbed - New Disease.mp3\000\000\000\000\000\000\000 > \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000 > \000\000\000\000\000\000\000\000\000\000\000\000\000\0100n\000\000\000 > \000\000\000\000\000\000\000\000\000\377\377\377\377\000\000\t \000 > \000\000\000\000\000\000\000\000\000\000\000\000\000\000\tDisturbed > \000\000\020\000\010\000\000\276u#\215\000\000\000\021\000\010\000\000 > \000\000\000\000\000\000\000\001\000\020\000\010,H\000\005\316\221\000 > \005\316[\000\000j\242\000\002\000CMacintosh > HD:Users:thez:Music:Disturbed:disturbed - New Disease.mp3\000\000\016 > \0008\000\e\000d\000i\000s\000t\000u\000r\000b\000e\000d\000 \000- > \000 \000N\000e\000w\000 \000D\000i\000s\000e\000a\000s\000e\000.\000m > \000p\0003\000\017\000\032\000\f\000M\000a\000c\000i\000n\000t\000o > \000s\000h\000 \000H\000D\000\022\0006Users/thez/Music/Disturbed/ > disturbed - New Disease.mp3\000\023\000\001/\000\000\025\000\002\000\v > \377\377\000\000" > > > It looks like type 'alis' is not one of the data types that gets > automatically converted to Ruby. Is there any chance of adding > support for this? Perhaps converting it to a String or a Pathname > object? > > Thanks! > > Zachary Pinter > _______________________________________________ > Rubyosa-discuss mailing list > Rubyosa-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/rubyosa-discuss From dustym at gmail.com Tue Oct 31 13:35:54 2006 From: dustym at gmail.com (Dusty Matthews) Date: Tue, 31 Oct 2006 12:35:54 -0600 Subject: [Rubyosa-discuss] Image Events In-Reply-To: References: <8641CBBE-30EE-4920-9F49-83AD6038316D@gmail.com> Message-ID: <79F136AC-8FE3-4CA2-B181-1F2982FBBABE@gmail.com> On Oct 31, 2006, at 10:41 AM, Tom Brice wrote: > On Oct 30, 2006, at 7:56 PM, Dusty Matthews wrote: > >> Has anyone tried using Image Events with RubyOSA? I can call OSA.app >> ('Image Events') and get all sorts of interesting stuff from that and >> rdoc-osa, but at the end of the day I can't figure out how to get an >> OSA::ImageEvents::Item that represents an existing image. >> >> For example, >> >> i = OSA.app('Image Events') >> i.open('some image') >> >> doesn't work because open is private. >> OSA::ImageEvents::Application#items returns a list of items >> associated with the app instance, but I don't know how to create or >> push those items into the instance in the first place. >> >> I think I might have a fundamental misunderstanding of how Image >> Events interacts with existing files? >> >> Thanks for the help. >> dusty > > Dusty, > you might be interested in the fact that the commandline utility > `sips`[1] does much of what ImageEvents can do so if you need a > quick fix that might work for you. > > I also want to put in my $.02 here. I think file handles are the > most opaque part of rubyosa right now. It appears that in some > cases you can use an absolute path but not always (as evidenced > above). Much of my Applescripting involves doing stuff with files: > > set aFile to "path:to:my:file" > > The analog to this in rubyosa needs to be clarified. > > Thanks in advance, > Tom > > [1] http://www.hmug.org/man/1/sips.php Tom, I'm already using a sips wrapper for simple resizing, etc, but I intend on more or less duplicating the whole feature-set (transforms, conversion, property key access, etc -- minus some color profile stuff I don't need) using OSA. sips is awesome, but I feel dirty doing all that shell argument munging. Thanks for the heads up, however. dusty From jmacaulay at gmail.com Tue Oct 31 19:12:42 2006 From: jmacaulay at gmail.com (James MacAulay) Date: Tue, 31 Oct 2006 19:12:42 -0500 Subject: [Rubyosa-discuss] OSA::Element of type alis In-Reply-To: <3403FC5C-1712-42FE-9C04-784FF255214B@zacharypinter.com> References: <3403FC5C-1712-42FE-9C04-784FF255214B@zacharypinter.com> Message-ID: <5A8392CC-1638-492B-9322-D410AF7BFF3A@gmail.com> (Replying to the list, since this may be of general interest.) From what I gather, __data__ is a reader method which also happens to have an optional argument to coerce the original data into different Apple Event types ('furl', etc.). Without arguments, it just uses the original type. Also, for what it's worth, I realized that the sample code I included wouldn't actually work since ...playlists[0].tracks[0] doesn't return as a File_track, which is needed for the location method. The way I access it in my project would more closely resemble OSA.app_with_name('iTunes').sources[0].library_playlists [0].file_tracks[0].location ...and so forth. -James On 31-Oct-06, at 4:09 PM | Oct 31, Zachary Pinter wrote: > Thanks James, > > That's exactly what I was looking for. I'm curious though, if > __data__ is just a String, how does the call __data__('furl') work? > > Zachary Pinter > > On Oct 31, 2006, at 11:05 AM, James MacAulay wrote: > >> Hi Zachary, >> >> I'm working on an iTunes project with RubyOSA as well, and this is >> how I deal with 'alis' objects: >> >> --- >> require 'rbosa' >> require 'uri' #(if necessary) >> # ... >> track = OSA.app_with_name('iTunes').sources[0].playlists[0].tracks[0] >> # (or whatever) >> >> pathname = URI.decode(URI.parse(track.location.__data__ >> ('furl')).path) >> # => "/Users/jmacaulay/Music/iTunes/iTunes Music/.../.../ >> whatever.mp3" >> --- >> >> Then you can do File.new(pathname) or whatever you want in ruby. >> >> -James >> >> On 31-Oct-06, at 9:08 AM | Oct 31, Zachary Pinter wrote: >> >>> Hi everybody, >>> >>> First off, thank you for this API. I've been experimenting with >>> trying to get the file name of songs in my iTunes library (with the >>> long term idea of accessing iTunes files and ratings over DRB). I've >>> come up with the following: >>> >>> require 'rubygems' >>> require_gem 'rubyosa' >>> require 'rbosa' >>> >>> itunes = OSA.app('itunes') >>> >>> library = itunes.sources.find{|s| s.name == "Library"} >>> library_playlist = library.library_playlists[0] >>> >>> file_track = library_playlist.file_tracks[0] >>> >>> puts file_track.location >>> puts file_track.location.__type__ >>> p file_track.location.__data__ >>> >>> Which produces: >>> # >>> alis >>> "\000\000\000\000\001\274\000\002\000\000\fMacintosh HD\000\000\000 >>> \000\000\000\000\000\000\000\000\000\000\000\000\276t\317-H+\000\000 >>> \000\010,H\edisturbed - New Disease.mp3\000\000\000\000\000\000\000 >>> \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000 >>> \000\000\000\000\000\000\000\000\000\000\000\000\000\0100n\000\000 >>> \000 >>> \000\000\000\000\000\000\000\000\000\377\377\377\377\000\000\t \000 >>> \000\000\000\000\000\000\000\000\000\000\000\000\000\000\tDisturbed >>> \000\000\020\000\010\000\000\276u#\215\000\000\000\021\000\010\000 >>> \000 >>> \000\000\000\000\000\000\000\001\000\020\000\010,H\000\005\316\221 >>> \000 >>> \005\316[\000\000j\242\000\002\000CMacintosh >>> HD:Users:thez:Music:Disturbed:disturbed - New Disease.mp3\000\000 >>> \016 >>> \0008\000\e\000d\000i\000s\000t\000u\000r\000b\000e\000d\000 \000- >>> \000 \000N\000e\000w\000 \000D\000i\000s\000e\000a\000s\000e\000. >>> \000m >>> \000p\0003\000\017\000\032\000\f\000M\000a\000c\000i\000n\000t\000o >>> \000s\000h\000 \000H\000D\000\022\0006Users/thez/Music/Disturbed/ >>> disturbed - New Disease.mp3\000\023\000\001/\000\000\025\000\002 >>> \000\v >>> \377\377\000\000" >>> >>> >>> It looks like type 'alis' is not one of the data types that gets >>> automatically converted to Ruby. Is there any chance of adding >>> support for this? Perhaps converting it to a String or a Pathname >>> object? >>> >>> Thanks! >>> >>> Zachary Pinter >>> _______________________________________________ >>> Rubyosa-discuss mailing list >>> Rubyosa-discuss at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rubyosa-discuss >> >> _______________________________________________ >> Rubyosa-discuss mailing list >> Rubyosa-discuss at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rubyosa-discuss > From jeanpierre at gmail.com Tue Oct 31 21:18:06 2006 From: jeanpierre at gmail.com (jeanpierre at gmail.com) Date: Tue, 31 Oct 2006 18:18:06 -0800 Subject: [Rubyosa-discuss] OSA::Element of type alis In-Reply-To: <5A8392CC-1638-492B-9322-D410AF7BFF3A@gmail.com> References: <3403FC5C-1712-42FE-9C04-784FF255214B@zacharypinter.com> <5A8392CC-1638-492B-9322-D410AF7BFF3A@gmail.com> Message-ID: this is getting pretty tricky, is there a way to get a OSA::ITunes::FileTrack from a OSA::ITunes::Track and vice versa? i'm hoping there is a better way than just matching their array position up. the applescript to do something similar seems simple enough, but i'm not sure what it means in rubyosa terms: set filepath to location of track turning/converting a ruby File into something usable in the OSA world would be most helpful as well =) thanks for your pointers on __data__ it helps push things forward. cheers, jean-pierre On 10/31/06, James MacAulay wrote: > (Replying to the list, since this may be of general interest.) > > From what I gather, __data__ is a reader method which also happens > to have an optional argument to coerce the original data into > different Apple Event types ('furl', etc.). Without arguments, it > just uses the original type. > > Also, for what it's worth, I realized that the sample code I included > wouldn't actually work since ...playlists[0].tracks[0] doesn't return > as a File_track, which is needed for the location method. The way I > access it in my project would more closely resemble > > OSA.app_with_name('iTunes').sources[0].library_playlists > [0].file_tracks[0].location > > ...and so forth. > > -James > > > On 31-Oct-06, at 4:09 PM | Oct 31, Zachary Pinter wrote: > > > Thanks James, > > > > That's exactly what I was looking for. I'm curious though, if > > __data__ is just a String, how does the call __data__('furl') work? > > > > Zachary Pinter > > > > On Oct 31, 2006, at 11:05 AM, James MacAulay wrote: > > > >> Hi Zachary, > >> > >> I'm working on an iTunes project with RubyOSA as well, and this is > >> how I deal with 'alis' objects: > >> > >> --- > >> require 'rbosa' > >> require 'uri' #(if necessary) > >> # ... > >> track = OSA.app_with_name('iTunes').sources[0].playlists[0].tracks[0] > >> # (or whatever) > >> > >> pathname = URI.decode(URI.parse(track.location.__data__ > >> ('furl')).path) > >> # => "/Users/jmacaulay/Music/iTunes/iTunes Music/.../.../ > >> whatever.mp3" > >> --- > >> > >> Then you can do File.new(pathname) or whatever you want in ruby. > >> > >> -James > >> > >> On 31-Oct-06, at 9:08 AM | Oct 31, Zachary Pinter wrote: > >> > >>> Hi everybody, > >>> > >>> First off, thank you for this API. I've been experimenting with > >>> trying to get the file name of songs in my iTunes library (with the > >>> long term idea of accessing iTunes files and ratings over DRB). I've > >>> come up with the following: > >>> > >>> require 'rubygems' > >>> require_gem 'rubyosa' > >>> require 'rbosa' > >>> > >>> itunes = OSA.app('itunes') > >>> > >>> library = itunes.sources.find{|s| s.name == "Library"} > >>> library_playlist = library.library_playlists[0] > >>> > >>> file_track = library_playlist.file_tracks[0] > >>> > >>> puts file_track.location > >>> puts file_track.location.__type__ > >>> p file_track.location.__data__ > >>> > >>> Which produces: > >>> # > >>> alis > >>> "\000\000\000\000\001\274\000\002\000\000\fMacintosh HD\000\000\000 > >>> \000\000\000\000\000\000\000\000\000\000\000\000\276t\317-H+\000\000 > >>> \000\010,H\edisturbed - New Disease.mp3\000\000\000\000\000\000\000 > >>> \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000 > >>> \000\000\000\000\000\000\000\000\000\000\000\000\000\0100n\000\000 > >>> \000 > >>> \000\000\000\000\000\000\000\000\000\377\377\377\377\000\000\t \000 > >>> \000\000\000\000\000\000\000\000\000\000\000\000\000\000\tDisturbed > >>> \000\000\020\000\010\000\000\276u#\215\000\000\000\021\000\010\000 > >>> \000 > >>> \000\000\000\000\000\000\000\001\000\020\000\010,H\000\005\316\221 > >>> \000 > >>> \005\316[\000\000j\242\000\002\000CMacintosh > >>> HD:Users:thez:Music:Disturbed:disturbed - New Disease.mp3\000\000 > >>> \016 > >>> \0008\000\e\000d\000i\000s\000t\000u\000r\000b\000e\000d\000 \000- > >>> \000 \000N\000e\000w\000 \000D\000i\000s\000e\000a\000s\000e\000. > >>> \000m > >>> \000p\0003\000\017\000\032\000\f\000M\000a\000c\000i\000n\000t\000o > >>> \000s\000h\000 \000H\000D\000\022\0006Users/thez/Music/Disturbed/ > >>> disturbed - New Disease.mp3\000\023\000\001/\000\000\025\000\002 > >>> \000\v > >>> \377\377\000\000" > >>> > >>> > >>> It looks like type 'alis' is not one of the data types that gets > >>> automatically converted to Ruby. Is there any chance of adding > >>> support for this? Perhaps converting it to a String or a Pathname > >>> object? > >>> > >>> Thanks! > >>> > >>> Zachary Pinter > >>> _______________________________________________ > >>> Rubyosa-discuss mailing list > >>> Rubyosa-discuss at rubyforge.org > >>> http://rubyforge.org/mailman/listinfo/rubyosa-discuss > >> > >> _______________________________________________ > >> Rubyosa-discuss mailing list > >> Rubyosa-discuss at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rubyosa-discuss > > > > _______________________________________________ > Rubyosa-discuss mailing list > Rubyosa-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/rubyosa-discuss > From jmacaulay at gmail.com Tue Oct 31 21:43:38 2006 From: jmacaulay at gmail.com (James MacAulay) Date: Tue, 31 Oct 2006 21:43:38 -0500 Subject: [Rubyosa-discuss] OSA::Element of type alis In-Reply-To: References: <3403FC5C-1712-42FE-9C04-784FF255214B@zacharypinter.com> <5A8392CC-1638-492B-9322-D410AF7BFF3A@gmail.com> Message-ID: <9A83FF15-5959-4DBE-BF63-86D9C4A947BE@gmail.com> On 31-Oct-06, at 9:18 PM | Oct 31, jeanpierre at gmail.com wrote: > this is getting pretty tricky, is there a way to get a > OSA::ITunes::FileTrack from a OSA::ITunes::Track and vice versa? You can force a Track to become the FileTrack that it truly is by using the methods Laurent outlined in an earlier post: http://rubyforge.org/pipermail/rubyosa-discuss/2006-October/000020.html So one way, for example, is with #get: irb(main):002:0> app = OSA.app_with_name('iTunes') => # irb(main):003:0> track = app.sources[0].playlists[0].tracks[0] => # irb(main):004:0> track.get => # Since Track inherits from FileTrack, I don't think there would be much need to convert in the other direction. > > turning/converting a ruby File into something usable in the OSA world > would be most helpful as well =) > I agree :) You can still use regular path strings to do searches and stuff, though, in case that's the kind of thing you wanted: searchable_location = URI.encode("/Users/jmacaulay/Music/iTunes/ iTunes Music/Some Artist/Some Album/Some Song.mp3") tracks = OSA.app_with_name('iTunes').playlists[0].tracks tracks.find { |t| URI.parse(t.location.__data__('furl')).path == searchable_location } -James From lrz at chopine.be Tue Oct 31 21:50:26 2006 From: lrz at chopine.be (Laurent Sansonetti) Date: Wed, 1 Nov 2006 03:50:26 +0100 Subject: [Rubyosa-discuss] OSA::Element of type alis In-Reply-To: References: Message-ID: Hi James, Interesting investigation. What about: <<<<< Index: src/lib/rbosa.rb =================================================================== --- src/lib/rbosa.rb (revision 103) +++ src/lib/rbosa.rb (working copy) @@ -772,6 +772,7 @@ # File name. # Let's use the 'furl' type here instead of 'alis', as we don't have a way to produce an alias for a file that does not exist yet. OSA.add_conversion_to_osa('alias', 'file') { |value| ['furl', value.to_s] } +OSA.add_conversion_to_ruby('alis') { |value, type, object| object.__data__('furl') } # Hash. OSA.add_conversion_to_ruby('reco') { |value, type, object| object.is_a?(OSA::ElementRecord) ? object.to_hash : self } >>>>> With this: ruby -I. -I./src/lib -r rbosa -e "p OSA .app('iTunes').sources[0].library_playlists[0].file_tracks[42].location" "file://localhost/Volumes/Data/music/Ali%20Project/Noir/20%20Family%20Affection.mp3 " I wonder if we should implicitly use the 'uri' lib to return the real path though, as it wouldn't work for non-file URLs (http & co). Laurent On Oct 31, 2006, at 6:05 PM, James MacAulay wrote: > Hi Zachary, > > I'm working on an iTunes project with RubyOSA as well, and this is > how I deal with 'alis' objects: > > --- > require 'rbosa' > require 'uri' #(if necessary) > # ... > track = OSA.app_with_name('iTunes').sources[0].playlists[0].tracks[0] > # (or whatever) > > pathname = URI.decode(URI.parse(track.location.__data__('furl')).path) > # => "/Users/jmacaulay/Music/iTunes/iTunes Music/.../.../whatever.mp3" > --- > > Then you can do File.new(pathname) or whatever you want in ruby. > > -James > > On 31-Oct-06, at 9:08 AM | Oct 31, Zachary Pinter wrote: > >> Hi everybody, >> >> First off, thank you for this API. I've been experimenting with >> trying to get the file name of songs in my iTunes library (with the >> long term idea of accessing iTunes files and ratings over DRB). I've >> come up with the following: >> >> require 'rubygems' >> require_gem 'rubyosa' >> require 'rbosa' >> >> itunes = OSA.app('itunes') >> >> library = itunes.sources.find{|s| s.name == "Library"} >> library_playlist = library.library_playlists[0] >> >> file_track = library_playlist.file_tracks[0] >> >> puts file_track.location >> puts file_track.location.__type__ >> p file_track.location.__data__ >> >> Which produces: >> # >> alis >> "\000\000\000\000\001\274\000\002\000\000\fMacintosh HD\000\000\000 >> \000\000\000\000\000\000\000\000\000\000\000\000\276t\317-H+\000\000 >> \000\010,H\edisturbed - New Disease.mp3\000\000\000\000\000\000\000 >> \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000 >> \000\000\000\000\000\000\000\000\000\000\000\000\000\0100n >> \000\000\000 >> \000\000\000\000\000\000\000\000\000\377\377\377\377\000\000\t \000 >> \000\000\000\000\000\000\000\000\000\000\000\000\000\000\tDisturbed >> \000\000\020\000\010\000\000\276u# >> \215\000\000\000\021\000\010\000\000 >> \000\000\000\000\000\000\000\001\000\020\000\010,H >> \000\005\316\221\000 >> \005\316[\000\000j\242\000\002\000CMacintosh >> HD:Users:thez:Music:Disturbed:disturbed - New Disease.mp3\000\000\016 >> \0008\000\e\000d\000i\000s\000t\000u\000r\000b\000e\000d\000 \000- >> \000 \000N\000e\000w\000 \000D\000i\000s\000e\000a\000s\000e >> \000.\000m >> \000p\0003\000\017\000\032\000\f\000M\000a\000c\000i\000n\000t\000o >> \000s\000h\000 \000H\000D\000\022\0006Users/thez/Music/Disturbed/ >> disturbed - New >> Disease.mp3\000\023\000\001/\000\000\025\000\002\000\v >> \377\377\000\000" >> >> >> It looks like type 'alis' is not one of the data types that gets >> automatically converted to Ruby. Is there any chance of adding >> support for this? Perhaps converting it to a String or a Pathname >> object? >> >> Thanks! >> >> Zachary Pinter >> _______________________________________________ >> Rubyosa-discuss mailing list >> Rubyosa-discuss at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rubyosa-discuss > > _______________________________________________ > Rubyosa-discuss mailing list > Rubyosa-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/rubyosa-discuss From lrz at chopine.be Tue Oct 31 22:07:42 2006 From: lrz at chopine.be (Laurent Sansonetti) Date: Wed, 1 Nov 2006 04:07:42 +0100 Subject: [Rubyosa-discuss] OSA::Element of type alis In-Reply-To: References: <3403FC5C-1712-42FE-9C04-784FF255214B@zacharypinter.com> <5A8392CC-1638-492B-9322-D410AF7BFF3A@gmail.com> Message-ID: On Nov 1, 2006, at 3:18 AM, jeanpierre at gmail.com wrote: > this is getting pretty tricky, is there a way to get a > OSA::ITunes::FileTrack from a OSA::ITunes::Track and vice versa? i'm > hoping there is a better way than just matching their array position > up. the applescript to do something similar seems simple enough, but > i'm not sure what it means in rubyosa terms: > set filepath to location of track > Yes, you can call #get on the track, and it will resolve itself into a FileTrack if it's one. The problem is that we don't know the real type of objects before resolving them (e.g. sending an apple event), and we try to minimize the send of events (if lazy_events is true, which is the default). The #tracks method of OSA::ITunes::Playlist as defined in the sdef returns a set of Track objects (which may be FileTrack, SharedTrack, etc...). So RubyOSA uses the Track class by default for this method. I understand that this is sometimes problematic like this case, I may come with a better solution in the future. > turning/converting a ruby File into something usable in the OSA world > would be most helpful as well =) > Would be interesting... I believe that we could build an alias for a given IO Ruby object (using the file descriptor from #fileno). Laurent > On 10/31/06, James MacAulay wrote: >> (Replying to the list, since this may be of general interest.) >> >> From what I gather, __data__ is a reader method which also happens >> to have an optional argument to coerce the original data into >> different Apple Event types ('furl', etc.). Without arguments, it >> just uses the original type. >> >> Also, for what it's worth, I realized that the sample code I included >> wouldn't actually work since ...playlists[0].tracks[0] doesn't return >> as a File_track, which is needed for the location method. The way I >> access it in my project would more closely resemble >> >> OSA.app_with_name('iTunes').sources[0].library_playlists >> [0].file_tracks[0].location >> >> ...and so forth. >> >> -James >> >> >> On 31-Oct-06, at 4:09 PM | Oct 31, Zachary Pinter wrote: >> >>> Thanks James, >>> >>> That's exactly what I was looking for. I'm curious though, if >>> __data__ is just a String, how does the call __data__('furl') work? >>> >>> Zachary Pinter >>> >>> On Oct 31, 2006, at 11:05 AM, James MacAulay wrote: >>> >>>> Hi Zachary, >>>> >>>> I'm working on an iTunes project with RubyOSA as well, and this is >>>> how I deal with 'alis' objects: >>>> >>>> --- >>>> require 'rbosa' >>>> require 'uri' #(if necessary) >>>> # ... >>>> track = >>>> OSA.app_with_name('iTunes').sources[0].playlists[0].tracks[0] >>>> # (or whatever) >>>> >>>> pathname = URI.decode(URI.parse(track.location.__data__ >>>> ('furl')).path) >>>> # => "/Users/jmacaulay/Music/iTunes/iTunes Music/.../.../ >>>> whatever.mp3" >>>> --- >>>> >>>> Then you can do File.new(pathname) or whatever you want in ruby. >>>> >>>> -James >>>> >>>> On 31-Oct-06, at 9:08 AM | Oct 31, Zachary Pinter wrote: >>>> >>>>> Hi everybody, >>>>> >>>>> First off, thank you for this API. I've been experimenting with >>>>> trying to get the file name of songs in my iTunes library (with >>>>> the >>>>> long term idea of accessing iTunes files and ratings over DRB). >>>>> I've >>>>> come up with the following: >>>>> >>>>> require 'rubygems' >>>>> require_gem 'rubyosa' >>>>> require 'rbosa' >>>>> >>>>> itunes = OSA.app('itunes') >>>>> >>>>> library = itunes.sources.find{|s| s.name == "Library"} >>>>> library_playlist = library.library_playlists[0] >>>>> >>>>> file_track = library_playlist.file_tracks[0] >>>>> >>>>> puts file_track.location >>>>> puts file_track.location.__type__ >>>>> p file_track.location.__data__ >>>>> >>>>> Which produces: >>>>> # >>>>> alis >>>>> "\000\000\000\000\001\274\000\002\000\000\fMacintosh HD >>>>> \000\000\000 >>>>> \000\000\000\000\000\000\000\000\000\000\000\000\276t\317-H+ >>>>> \000\000 >>>>> \000\010,H\edisturbed - New >>>>> Disease.mp3\000\000\000\000\000\000\000 >>>>> \000 >>>>> \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000 >>>>> \000\000\000\000\000\000\000\000\000\000\000\000\000\0100n\000\000 >>>>> \000 >>>>> \000\000\000\000\000\000\000\000\000\377\377\377\377\000\000\t >>>>> \000 >>>>> \000 >>>>> \000\000\000\000\000\000\000\000\000\000\000\000\000\tDisturbed >>>>> \000\000\020\000\010\000\000\276u#\215\000\000\000\021\000\010\000 >>>>> \000 >>>>> \000\000\000\000\000\000\000\001\000\020\000\010,H\000\005\316\221 >>>>> \000 >>>>> \005\316[\000\000j\242\000\002\000CMacintosh >>>>> HD:Users:thez:Music:Disturbed:disturbed - New Disease.mp3\000\000 >>>>> \016 >>>>> \0008\000\e\000d\000i\000s\000t\000u\000r\000b\000e\000d\000 \000- >>>>> \000 \000N\000e\000w\000 \000D\000i\000s\000e\000a\000s\000e\000. >>>>> \000m >>>>> \000p\0003\000\017\000\032\000\f\000M\000a\000c\000i\000n\000t >>>>> \000o >>>>> \000s\000h\000 \000H\000D\000\022\0006Users/thez/Music/Disturbed/ >>>>> disturbed - New Disease.mp3\000\023\000\001/\000\000\025\000\002 >>>>> \000\v >>>>> \377\377\000\000" >>>>> >>>>> >>>>> It looks like type 'alis' is not one of the data types that gets >>>>> automatically converted to Ruby. Is there any chance of adding >>>>> support for this? Perhaps converting it to a String or a Pathname >>>>> object? >>>>> >>>>> Thanks! >>>>> >>>>> Zachary Pinter >>>>> _______________________________________________ >>>>> Rubyosa-discuss mailing list >>>>> Rubyosa-discuss at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/rubyosa-discuss >>>> >>>> _______________________________________________ >>>> Rubyosa-discuss mailing list >>>> Rubyosa-discuss at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rubyosa-discuss >>> >> >> _______________________________________________ >> Rubyosa-discuss mailing list >> Rubyosa-discuss at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rubyosa-discuss >> > _______________________________________________ > Rubyosa-discuss mailing list > Rubyosa-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/rubyosa-discuss From jmacaulay at gmail.com Tue Oct 31 22:26:21 2006 From: jmacaulay at gmail.com (James MacAulay) Date: Tue, 31 Oct 2006 22:26:21 -0500 Subject: [Rubyosa-discuss] OSA::Element of type alis In-Reply-To: References: Message-ID: On 31-Oct-06, at 9:50 PM | Oct 31, Laurent Sansonetti wrote: /snip > +OSA.add_conversion_to_ruby('alis') { |value, type, object| > object.__data__('furl') } > /snip Yeah, this is probably the best way to go as far as I can tell. /snip > > I wonder if we should implicitly use the 'uri' lib to return the > real path though, as it wouldn't work for non-file URLs (http & co). > > Laurent So 'alis' objects are sometimes used for remote URLs? I just assumed that is one thing which separated the use of 'alis' vs. 'furl'. If we could safely assume that 'alis' objects are always going to represent files on mounted volumes, then we could even make ruby File objects out of them straight away. I guess this might introduce a fair amount of overhead when resolving a bunch of them, though. Just coercing the alis into a furl seems like a happy medium, at least until we or someone else makes a ruby class which converts more smoothly to and from alis without information loss (I really don't know what all the extra information in an alis is all about, anyway). -James From andy at pragmaticbookshelf.com Tue Oct 31 11:31:48 2006 From: andy at pragmaticbookshelf.com (Andy Hunt) Date: Tue, 31 Oct 2006 11:31:48 -0500 Subject: [Rubyosa-discuss] Sending keystrokes via System Events Message-ID: <0845848C-B3B9-48B8-8BCE-708FCCD47938@pragmaticbookshelf.com> Hi all, I've trying to send keystrokes to a process that isn't otherwise scriptable. There's a hunk of Applescript that does it like this: set processName to (...) tell application processName to activate tell application "System Events" tell process processName keystroke "n" using {command down, option down} ... end tell end tell How can I do this using RubyOsa? I'm not clear on the scope of the activate, the nesting, or passing parameters to "keystroke". But other than that... :-) thanks, /\ndy From zpinter at zacharypinter.com Mon Oct 30 10:30:30 2006 From: zpinter at zacharypinter.com (zpinter at zacharypinter.com) Date: Mon, 30 Oct 2006 15:30:30 +0000 (GMT) Subject: [Rubyosa-discuss] OSA::Element of type alis References: <45461a4e63daa_71ce6eecd2a2c9@web1.sr.joyent.net.tmail> Message-ID: <45461a4e63daa_71ce6eecd2a2c9@web1.sr.joyent.net.tmail> Hi everybody, First off, thank you for this API. I've been experimenting with trying to get the file name of songs in my iTunes library (with the long term idea of accessing iTunes files and ratings over DRB). I've come up with the following: require 'rubygems' require_gem 'rubyosa' require 'rbosa' itunes = OSA.app('itunes') library = itunes.sources.find{|s| s.name == "Library"} library_playlist = library.library_playlists[0] file_track = library_playlist.file_tracks[0] puts file_track.location puts file_track.location.__type__ p file_track.location.__data__ Which produces: # alis "\000\000\000\000\001\274\000\002\000\000\fMacintosh HD\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\276t\317-H+\000\000\000\010,H\edisturbed - New Disease.mp3\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\0100n\000\000\000\000\000\000\000\000\000\000\000\000\377\377\377\377\000\000\t \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\tDisturbed\000\000\020\000\010\000\000\276u#\215\000\000\000\021\000\010\000\000\000\000\000\000\000\000\000\001\000\020\000\010,H\000\005\316\221\000\005\316[\000\000j\242\000\002\000CMacintosh HD:Users:thez:Music:Disturbed:disturbed - New Disease.mp3\000\000\016\0008\000\e\000d\000i\000s\000t\000u\000r\000b\000e\000d\000 \000-\000 \000N\000e\000w\000 \000D\000i\000s\000e\000a\000s\000e\000.\000m\000p\0003\000\017\000\032\000\f\000M\000a\000c\000i\000n\000t\000o\000s\000h\000 \000H\000D\000\022\0006Users/thez/Music/Dist urbed/disturbed - New Disease.mp3\000\023\000\001/\000\000\025\000\002\000\v\377\377\000\000" It looks like type 'alis' is not one of the data types that gets automatically converted to Ruby. Is there any chance of adding support for this? Perhaps converting it to a String or a Pathname object? Thanks! Zachary Pinter