• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [Slightly OT] Scripting Bridge in Leopard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Slightly OT] Scripting Bridge in Leopard


  • Subject: Re: [Slightly OT] Scripting Bridge in Leopard
  • From: has <email@hidden>
  • Date: Fri, 2 Nov 2007 19:48:21 +0000

On 1 Nov 2007, at 13:21, Rob Stott wrote:

I was kind of wondering whether anyone had a working example so I could compare theirs to my ham-fisted effort!

Still working on fully grokking SB myself, but if you're curious, here's a really basic comparison I just whipped up between AppleScript, SB, appscript and Mac::Glue:



------- AppleScript -------

#!/usr/bin/osascript

tell application id "com.apple.textedit"
    get paragraph 1 of document "Read Me.txt"
end tell


------- Scripting Bridge (via PyObjC) -------

#!/usr/bin/python

from ScriptingBridge import *

textedit = SBApplication.alloc().initWithBundleIdentifier_('com.apple.textedit')
print `textedit.documents().objectWithName_('Read Me.txt').text().paragraphs()[0].get()`



------- py-appscript [1] -------

#!/usr/bin/python

from appscript import *

textedit = app(id='com.apple.textedit')
print `textedit.documents['Read Me.txt'].paragraphs[1].get()`


------- Mac::Glue [2] -------

#!/usr/bin/perl

use Mac::Glue;

my $te = new Mac::Glue('TextEdit');
print $te->obj('document' => 'Read Me.txt')->obj('paragraph' => 1)->get;



I'll try to post some less trivial examples as and when time allows.

has

[1] Folks wanting to use appscript on Leopard's stock Python install should download and unpack 'appscript-0.17.2.tar.gz' from <http://appscript.sourceforge.net >, cd to the appscript-0.17.2 folder and run 'python setup.py install'. (Note that you'll need to have gcc - included in Apple's Dev Tools - installed.) New binary installers, eggs, etc. are on my TODO list for later this month.

[2] To make a TextEdit glue, run: sudo gluemac /Applications/ TextEdit.app

--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: [Slightly OT] Scripting Bridge in Leopard
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Re: [Slightly OT] Scripting Bridge in Leopard (From: Rob Stott <email@hidden>)

  • Prev by Date: Re: prevent user input question
  • Next by Date: Re: prevent user input question
  • Previous by thread: Re: [Slightly OT] Scripting Bridge in Leopard
  • Next by thread: Re: [Slightly OT] Scripting Bridge in Leopard
  • Index(es):
    • Date
    • Thread