MACSCRPT Archives

May 2003

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Nobumi Iyanaga <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Thu, 8 May 2003 18:34:45 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (59 lines)
Hello John and Emmanuel,

Thank you for your reply.

On Wednesday, May 7, 2003, at 08:30  PM, John Delacour wrote:

> 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
>

This means that practically, it is impossible to "tell the frontmost 
application"... (except for some applications that can trigger scripts 
on their own.  -- But in these cases, "tell" iself is not needed, as 
John has pointed out in the Nisus mainling list...).
In Frontier, we can write for example a script like this:

on testscript () {
        system.verbs.apps.style.bringToFront ();
        system.verbs.apps.style.openDocument ("Macintosh 
HD:Users:ni:Desktop:myscript.pl");
        local (appname = sys.frontmostApp (), wname);
        with objectModel {
                wname = system.verbs.apps[appname].get (document [1].name)};
        dialog.notify (wname)}

and call it from (for example) Nisus Writer.

I think this is possible because Frontier is running fully at the 
background.  Perhaps System Events is not really running at the 
background...??

Best regards,

Nobumi Iyanaga
Tokyo,
Japan

ATOM RSS1 RSS2