• 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: how to tell application using psn
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
echo email@hidden@nl | tr a-z@. p-za-o.@

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

References: 
 >how to tell application using psn (From: Joel Sherriff <email@hidden>)

  • Prev by Date: Re: another short form
  • Next by Date: set optionKeyDown to...
  • Previous by thread: how to tell application using psn
  • Next by thread: Re: how to tell application using psn
  • Index(es):
    • Date
    • Thread