Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Application process name
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Application process name



On Thursday, February 27, 2003, at 02:52 AM, Bill Cheeseman wrote:

Apparently so. Because of the different naming for applications and
application processes in some circumstances, we end up having to write
slightly confusing scripts like this (if we've renamed Adobe Photoshop 7.0
to "Photoshop" in the Finder):

tell application "Photoshop" to activate
tell application "System Events"
tell application process "Adobe Photoshop 7.0"
....

Yes, this is all less than ideal. I'd like to straighten it out, but it'll be a while.

Two more questions:

1. The processes.h header says of GetProcessInformation that "the .processName field must point to ... a Str31 structure in the caller's memory space...." ... [T]his suggests that System Events (and AppleScript) will choke on an application whose process name (apparently the
name of the executable in an application bundle) is greater than 31 characters in length under Mac OS X.

Well, it would, except that GetProcessInformation will mangle the name down to less than 32 characters if it needs to, same as happens for FSSpecs. The upshot is that it'll work, but you'll get an even weirder result than you expected.

I started out declaring my process name variable as Str31 in accordance with
the processes.h comment, but in light of MacTypes.h I'm inclined to change
it to StringPtr and let the chips fall where they may. Oops! That crashes.
Back to Str31.

Right. StringPtr is a pointer to an array of unsigned char, which is not the same thing at all as a pointer to a pointer.

2. Does AppleScript these days expect to see the "display name" in 'tell application "<app name>"' constructs, or something else? I'm familiar with "display name" as a Cocoa feature, returning the app name with or without the ".app" extension depending on the user's settings; I don't know how this is handled in Carbon. To frame my question more exactly, what call should a developer use to generate the same application name that AppleScript expects
to see in a 'tell' statement?

First, remember that this is only an issue at compilation time. Compiled scripts track applications using aliases (and failing that, the creator code), so they don't care what the name of the application is. (Unless both the alias and creator code fail, in which case they'll fall back on the name.)

When looking up an application by name, AppleScript looks for the name...

1. ...in GetProcessInformation -- obviously, the application has to be running for this to work.
2. ...using LSFindApplicationForInfo, which I believe uses the application file name. (Technically, LS uses the exact file name with the ".app", but AppleScript will add the ".app" if necessary.)

To determine #1, use GetProcessInformation with the appropriate psn; to determine the second, use FSGetCatalogInfo with the appropriate FSRef.

Remind me why you need to do this?


--Chris Nebel
AppleScript Engineering
_______________________________________________
applescript-implementors mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-implementors
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Application process name (From: Bill Cheeseman <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.