Re: Tell print/close to the frontmost app
Re: Tell print/close to the frontmost app
- Subject: Re: Tell print/close to the frontmost app
- From: Mr Tea <email@hidden>
- Date: Thu, 19 Sep 2002 12:19:56 +0100
This from Stephane ODUL - dated 19-9-02 11.22 am:
>
tell frontmost application
>
close the front window
>
end tell
>
>
tell frontmost application
>
print the front window
>
end tell
>
>
Maybe I should send events ?
>
>
I'm very unfamiliar with apple script...
Indeed. Actually, it would be quite nice if the above scripts worked, but as
you've found out, Stephane, they don't. Applescript is not quite _that_
easy.
You have to be more specific than 'tell frontmost application', for a start.
A tell block is usually directed at a named application, because there is a
risk that the frontmost application is not the one that your script expects
- it may not even be scriptable.
Also, different applications use different applescript terms to describe the
same thing. 'Window' is a case in point. Some applications call open
document windows 'windows', some call them 'documents', and in some the
terms are interchangeable. And there's more. Most apps will understand the
term 'front', but some won't, and you will need to refer to 'document 1' or
'window 1'. And when you close a document window, you have to take into
account whether the document needs to be saved or not. And when you print,
you need to consider the fact that the print dialog will pop up unless you
are scripting an app that allows you to bypass this...
Are you still with me?
If you can tell us the applications that you want to work with, we can be
more helpful. Every scriptable application has its own scripting dictionary,
which you can look at from within your script editor, and I suggest you take
a look at the dictionaries for the apps you want to script, and any examples
that you can find.
That being said, it is possible to send commands to the 'frontmost
application' without naming it in your script.
The Finder acts as a sort of warden for all the running processes, at least
as far as Applescript is concerned, so you need to ask it politely what the
frontmost process is:
tell application "Finder"
set theAppName to name of (every process whose frontmost is true) as
string
end tell
tell application theAppName
display dialog theAppName & " is frontmost"
end tell
HTH
Nick
_______________________________________________
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.