• 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: calling the run method in an AppleScript from a cocoa application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: calling the run method in an AppleScript from a cocoa application


  • Subject: Re: calling the run method in an AppleScript from a cocoa application
  • From: "email@hidden" <email@hidden>
  • Date: Fri, 12 Mar 2010 17:20:33 +0000

On 12 Mar 2010, at 16:56, David Alter wrote:

> I need the ability to call an AppleScript from a Cocoa Application. I have
> done this in the past using NSAppleScript and it works great. This time I
> need to call the "on run" and pass in parameters. That I have not done. I
> looked at the following Tech note Technical Note TN2084: Using AppleScript
> Scripts in Cocoa
> Applications<http://developer.apple.com/mac/library/technotes/tn2006/tn2084.html#TNTAG5>
> and
> it talks about running a subroutine in apple script and passing in
> parameters. The example I have been able to get working, but if I try and
> call the run method it does not work. I suspect it is the event parameter
> that is incorrect.
>
> Here is code. It is basically the same code that was in the tech note but it
> is calling "run" as appose to "sow_message". Run is a reserved word and
> clearly acts differently.
>
> NSAppleEventDescriptor* handler =
>
> [NSAppleEventDescriptor descriptorWithString:
>
> [@"run" lowercaseString]]; //here is where I'm trying to setup the
> subroutine to call
>
> NSAppleEventDescriptor* event =
>
> [NSAppleEventDescriptor appleEventWithEventClass:kASAppleScriptSuite
>
> eventID:kASSubroutineEvent //I suspect that this eventID is not correct.
>
> targetDescriptor:target
>
> returnID:kAutoGenerateReturnID
>
> transactionID:kAnyTransactionID];
>
> [event setParamDescriptor:handler forKeyword:keyASSubroutineName];       //I
> suspect that this is not needed or is incorrect
>
> [event setParamDescriptor:parameters forKeyword:keyDirectObject];
>
>
Try sending the open application event. Should do the trick.
The run handler can take parameters if desire.

theEvent = [self appleEventWithEventClass:kCoreEventClass eventID:kAEOpenApplication targetDescriptor:aTargetDescriptor returnID:kAutoGenerateReturnID transactionID:kAnyTransactionID];


Regards

Jonathan Mitchell

Developer
http://www.mugginsoft.com

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >calling the run method in an AppleScript from a cocoa application (From: David Alter <email@hidden>)

  • Prev by Date: Re: calling the run method in an AppleScript from a cocoa application
  • Next by Date: Key-Value Observing speed
  • Previous by thread: Re: calling the run method in an AppleScript from a cocoa application
  • Next by thread: Key-Value Observing speed
  • Index(es):
    • Date
    • Thread