Re: Using tell application "name" where the name comes from GUI Script...
Re: Using tell application "name" where the name comes from GUI Script...
- Subject: Re: Using tell application "name" where the name comes from GUI Script...
- From: Christopher Nebel <email@hidden>
- Date: Thu, 17 Apr 2003 13:23:41 -0700
On Thursday, April 17, 2003, at 04:32 AM, John Delacour wrote:
Any idea how I can get this to distinguish creator codes based on
case?
This looks like one of System Events many bugs.
considering case
tell application "System Events"
processes whose creator type is "toys"
end tell
end considering
--> {application process "Script Editor" of application "System
Events"}
It's a bug that System Events ignores "considering case." Of course,
pretty much all applications do. Bill's rationalization is just that:
a rationalization. The simple fact is that the founders screwed up and
didn't define a way for applications to find out what the current
considering/ignoring state was. (Actually, I think they did, but it
didn't work right.) We fixed this back in AppleScript 1.7, but haven't
been very forceful about evangelizing it.
Anyway, I've filed a bug against Cocoa Scripting. Until that's fixed,
your best bet is to extract the creator type into a variable and
compare it in AppleScript. For example:
tell application "System Events"
set docklike to every process whose creator type is "Dock"
repeat with p in docklike
get the creator type of p
considering case
if the result is "dock"
log "It's the Dock."
else if the result is "Dock"
log "It's DragThing."
end
end
end
end
I'm also wondering whether or not creator type (and by extension, file
type) should *always* compare case-sensitively. On the one hand,
they're inherently case-sensitive data, and comparing them
insensitively will probably only lead to unpleasant surprises. On the
other hand, it would be inconsistent with other string properties, and
might break existing scripts.
--Chris Nebel
Apple Development Tools
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.