Subject: | |
From: | |
Reply To: | |
Date: | Wed, 7 May 2003 12:30:39 +0100 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
At 6:48 pm +0900 7/5/03, Nobumi Iyanaga wrote:
> Is there any way to write a script:
>
> tell the frontmost application
> ...
> end tell
> ?
>
> It works in Script Editor if the script has been already saved and put
> the path of the script on the clipboard. But if I run it from Script
> Menu when TextEdit or other applications is active, it does not work:
> nothing is put on the clipboard.
You will see one of the problems if you run this script from the Script Menu:
using terms from application "System Events"
set proc1 to name of process 1 whose frontmost is true
end using terms from
display dialog proc1
Script Menu passes everything through System Events, so the frontmost
process whenever you run a script from there, is System Events, even
if you can't see it. I don't use Script Menu and think it's worth
buying iKey.
I think the best way to do it, if you must use Script menu, is as
below. Only cocoa documents have the property 'path', so you haven't
a wide choice.
tell application "Finder"
--all one line
set processnames to name of processes whose name is "TextEdit" or
name is "Nisus Writer Express" or name is "some other name"
-- end of line
end tell
set pathlist to {}
repeat with p in processnames
set p to contents of p
tell application p
set end of pathlist to «class ppth» of document 1
end tell
end repeat
choose from list pathlist default items pathlist with multiple
selections allowed
JD
|
|
|