Re: how to tell application using psn
Re: how to tell application using psn
- Subject: Re: how to tell application using psn
- From: Philip Aker <email@hidden>
- Date: Tue, 9 Sep 2008 07:32:56 -0700
On Sep 9, 2008, at 6:19 AM, Joel Sherriff wrote: I've read that this is doable, but I can't find a single example. Can someone show me how? I just want to execute a simple script like
tell application N name of windows end tell
where N is the psn of the app. If it's possible I'm assuming I just need to annotate it correctly. The background is that this script will be called from a cocoa app, if that helps.
You have a choice of means when working at this level. To translate from a PSN to a name look in Processes.h for ProcessInformationCopyDictionary() to get a name for a PSN. Otherwise using a PSN is the traditional way to set the target of an AppleEvent. Use typeProcessSerialNumber and the PSN you've obtained to set the target for AppleEvents. Using an AppleEvent directly instead of an AppleScript call will give you faster performance.
NSAppleEventDescriptor *psnDesc = [NSAppleEventDescriptor descriptorWithDescriptorType:typeProcessSerialNumber bytes:&psn length:sizeof( psn )];
+ (NSAppleEventDescriptor *)appleEventWithEventClass:(AEEventClass)eventClass eventID:(AEEventID)eventID targetDescriptor:psnDesc returnID:(AEReturnID)returnID transactionID:(AETransactionID)transactionID; Philip Aker
Democracy: Two wolves and a sheep voting on lunch. |
_______________________________________________
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