Re: Activating applications from a list
Re: Activating applications from a list
- Subject: Re: Activating applications from a list
- From: Paul Berkowitz <email@hidden>
- Date: Sat, 14 Dec 2002 17:22:29 -0800
On 12/14/02 4:51 PM, "Deivy Petrescu" <email@hidden> wrote:
>
> I would appreciate suggestions for making this script work.
>
>
OK.
>
Here:
>
>
tell application "Finder"
>
set opened_apps to name of every process
>
set selected_app to choose from list opened_apps with empty
>
selection allowed
>
set selected_app to selected_app as string
>
end tell
>
if (selected_app is not "") and (selected_app is not "false") then
>
tell application selected_app to activate
>
>
>
>
> 1) I'm not at all sure what one gets if the CANCEL button is pressed
>
> on a choose from list. The button definitions from dialog boxes
>
> don't seem to work and the dictionary seems to be flat out wrong.
It's not wrong, it's just leaves out some vital information!
choose from list list of string -- a list of strings to display (an
empty list if no selection)
If you
set c to choose from list {"a","b", "c"} with empty selection allowed
and then make no selection, the result will be
--> {}
If you press the Cancel button, then the result is
false
as Deivy says. So you have to be careful to allow for that when getting
'item 1 of result' - first make a special case for false.
if c is false then
error number -128
else -- if multiple selection not allowed
set c to item 1 of c
end if
Or - again if multiple selection is not allowed -
set c to (choose from list {"a","b", "c"} with empty selection allowed)
as string
if c is "false" then error number -128
--continue on your merry way
>
>
it retubns false! Yeah, I know and I agree, but read what you say in
>
your signature!
>
>
>
>
> 2) the command "activate" works when sent to a known application but
>
> seems not to be understood when the name is text from a list. Where
>
> is the term "activate" defined?
>
>
In the old "Scripting Additions" guide. Apparently, it's a "built-in
scripting addition", so it's not in the ASLG, nor is it a Standard addition.
Nuts, yes? It drove me crazy trying to find the term when I was learning
AppleScript. (Maybe it's an "addition" because they didn't include it in
v1.0? It should by now be part of the language and defined in the ASLG.)
>
>
you activate an application. You are telling a list to activate. It
>
will not work!
>
Of course. What exactly are you trying to do by "activating" a list? And
take note - you activate an application, like Deivy says, not a Finder
process. You can use the names you got from 'name of process' and cycle
through them or get the right one, then put 'application' before it, and
activate that.
--
Paul Berkowitz
_______________________________________________
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.