Re: (no subject)
Re: (no subject)
- Subject: Re: (no subject)
- From: KOENIG Yvan <email@hidden>
- Date: Mon, 16 Feb 2009 10:56:14 +0100
Le 16 févr. 2009 à 10:22:34, emile.a.schwarz a écrit :
Hi all,
before the question, I must say that I gooffed and found what I
wrote below.
I wanted to know what kind of data is in the front window: raw text
_or_ styled text. I do not found it.
Anyone knows ?
Here’s gooffy:
tell application "TextEdit"
-- wrong way to activate the TextEdit application
set frontmost of application "TextEdit" to true
-- Correct way to activate the TextEdit application
activate
end tell
1. The first line does not return an error even if the
“frontmost” property is read only (marked as is in the
dictionary).
2. The second line works fine (or nearly): even if I have two
windows, none of them are frontmost (activated). BUT, TextEdit is
frontmost (as asked).
Of course - this is the reason why I write this report - when the
first (and wrong) line is removed, activate do its job correctly:
there is a front window (an activated window).
FWIW,
Emile
Hello all of us, I know Emile for years so he will perfectly
understand that I'm not rude at all.
Hello Emile.
When a property is defined as read only, isn't it a bit foolish to
deliberately try to change it this way ?
I guess that it's why the programmer didn't thought that it was
useful to return an error for such an odd instruction.
You code is too long ;-)
tell application "TextEdit"
set frontmost to true
end tell
or
set frontmost of application "Textedit"
out of a tell block would be equivalent.
But the main thing is that the fact that an application is frontmost
doesn't prove that it is active.
Look at:
get frontmost of application "Mail"
delay 1
get frontmost of application "Pages"
delay 1
get frontmost of application "TextEdit"
I ran it from the Script Editor.
Mail had two windows open
Pages had none
Textedit had one
The log (under 10.4.11) states:
tell application "Mail"
get frontmost
false
end tell
tell application "Pages"
get frontmost
false
end tell
tell application "TextEdit"
get frontmost
true
end tell
So, why try to invent a new wheel to activate a program ?
Yvan KOENIG (from FRANCE lundi 16 février 2009 10:55:49)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
References: | |
| >(no subject) (From: "emile.a.schwarz" <email@hidden>) |