• 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: has <email@hidden>
  • Date: Tue, 9 Sep 2008 20:54:44 +0100

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.

PSNs not so much. You can target apps by PIDs in AS, but that involves messing about with eppc URLs and Remote Apple Events which introduces authentication/security issues.



The background is that this script will be called from a cocoa app, if that helps.


Unless the script is user-supplied, I would recommend foregoing AppleScript altogether and just using a Cocoa-Apple event bridge to talk to the application directly. For example, using objc-appscript, you might write something like:

// To create glue files: osaglue  -o FooGlue  -p Foo  Foo

#import "FooGlue/FooGlue.h"

- (NSArray *)windowNamesForPSN:(ProcessSerialNumber *)psn error: (NSError **)error {
pid_t pid;
OSStatus err = noErr;

if (error)
*error = nil;
err = GetProcessPID(psn, &pid);
if (err) {
*error = [NSError errorWithDomain: NSOSStatusErrorDomain code: err userInfo: nil];
return nil;
}


	FooApplication *foo = [FooApplication applicationWithPID: pid];
	FooReference *ref = [[foo windows] name];

	return [ref getListWithError: error];
}


HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

_______________________________________________
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
  • Follow-Ups:
    • Re: how to tell application using psn
      • From: email@hidden
  • Prev by Date: RE: another short form
  • Next by Date: Re: how to tell application using psn
  • Previous by thread: Re: how to tell application using psn
  • Next by thread: Re: how to tell application using psn
  • Index(es):
    • Date
    • Thread