[Pythonmac-SIG] Appscript and keystrokes

Bob Ippolito bob at redivi.com
Thu Jul 28 04:43:21 CEST 2005


On Jul 27, 2005, at 3:48 PM, Nathaniel Gray wrote:

> I'm trying to use Appscript to send keystrokes to iPhoto (sadly,
> there's no other way to get the job done), but I can't figure out how
> to make it work.  I thought it should work like this:
>
> ipe = app("System Events").processes['iPhoto']
> ipe.keystroke(u"foo")
>
> But this yields the error:
>
>>>> ipe.keystroke(u"foo")
>>>>
> ------------------------------------------------------------
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/System/Library/Frameworks/Python.framework/Versions/2.3/ 
> lib/python2.3/site-packages/appscript/specifier.py",
> line 203, in __call__
>     raise CommandError(self, (args, kargs), e)
> CommandError: Too many direct parameters: command was called on a
> reference but already has a direct parameter.
>         Failed command: app(u'/System/Library/CoreServices/System
> Events.app').processes['iPhoto'].keystroke(u'foo')

This error sounds like it wants you to pass a keyword argument  
instead of a positional argument ("direct parameter" in Apple Event  
speak).  I don't know much about appscript and I don't have iPhoto  
installed so I can't provide any specific advice.

-bob



More information about the Pythonmac-SIG mailing list