[Pythonmac-SIG] AppleEvents in MacPython 2.3?
Bob Ippolito
bob at redivi.com
Mon Aug 11 15:29:13 EDT 2003
Try aeve .. from http://undefined.org/python/
import aeve
textedit = aeve.talkto('/Applications/TextEdit.app')
print textedit.documents[0].text
Currently, I think aeve just coerces text to a python string and
doesn't give you access to asking for paragraph/word/etc. I'll
probably change that in the future.
-bob
The only reason the "word" stuff works is because AppleScript handles
that stuff internally
On Monday, Aug 11, 2003, at 14:13 America/New_York, Stonewall Ballard
wrote:
> I've been trying out Python for a few weeks, and have decided to
> convert to
> it for scripting. I had been using Perl and AppleScript for scripting.
> I'm
> on OS X 10.2.6.
>
> I spent many hours yesterday trying to figure out how to use the
> AppleScript
> support that comes with MacPython 2.3, and wasn't able to make much
> progress. Even a simple script like this:
>
> tell application "TextEdit"
> get word 1 of document 1
> end tell
>
> doesn't work. I guess I'm missing some understanding of how this works,
> since according to ScriptDebugger, "word" isn't an element of
> "document" in
> the first place. But somehow it works in AppleScript. Can anyone
> explain
> this?
>
> It would be really nice to have something that works like the MacPerl
> "doScript" command, which takes a string, compiles it as an
> AppleScript, and
> runs it. It's much easier to figure out how to drive AppleScriptable
> apps
> that way. Perhaps it's slower than sending apple events directly, but
> for my
> purposes, that doesn't matter.
>
> The archives of this group suggest that such a "doscript" facility
> used to
> exist, but I don't see it anywhere. Can someone tell me where I can
> find
> this if it exists?
>
> It would also be very helpful to see examples of Python sending Apple
> Events. The doc example is too trivial to help much. I'd greatly
> appreciate
> any source code that you all might want to share.
>
> Thanks for any help.
>
> - Stoney
>
> --
> Stonewall Ballard
> stoney at sb.org http://stoney.sb.org/
>
>
>
> _______________________________________________
> Pythonmac-SIG maillist - Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
More information about the Pythonmac-SIG
mailing list