On Sep 6, 2009, at 10:59 AM, Luther Fuller wrote: On Sep 6, 2009, at 12:17 PM, Mike Matthews wrote: On Sep 6, 2009, at 10:06 AM, Luther Fuller wrote: On Sep 6, 2009, at 11:42 AM, Mike Matthews wrote: I've been trying to find a way for this AppleScript (or something like it) to work:
tell application "Mail" set theContent to the content of the front window end tell
But it appears that there's no way to target the front window of Mail, including in the 10.6 version of Mail.
Message windows belong to a Viewer Window not the application. Try this ...
tell application "Mail" set frontViewer to (message viewer 1) set theMsg to message 2 of frontViewer content of theMsg end tell
--- Helpful, but it gets the content of the first message in the list of incoming messages of te selected mailbox in the mail viewer window.
I'd like the script to operate on an open outgoing message window that is front-most.
Sorry if this wasn't clear.
---
Thanks for clarifying that. The best I could do, so far, is ...
tell application "Mail" activate set frontViewer to (message viewer 1) set msgList to selected messages of frontViewer if (count items of msgList) ≠ 1 then beep return end if set frontMsg to (item 1 of msgList) content of frontMsg end tell
Notice that this script says nothing about the frontmost window. I tried finding a connection between 'window 1', which does not have 'content' and a particular message, which does. Mail seems to have a disconnect in that area. Or I haven't found it yet. I can find no way to associate a window with its message. (BTW, I display message content in a message window, not in the Message Viewer, which is an option. I just tried 'content of frontViewer' ... it does not work.)
Perhaps the best Mail can do is let you use 'selected messages' instead of the window of a message.
--- I've been trying to solve this one for many years, hoping that with each new OS revision, Mail's scripting dictionary would allow it. No such luck yet, I think.
I've been able to fudge it by manually selecting the text in the outgoing mail message and copying it to the clipboard and then running the script, but I'd sure like to eliminate that step.
I'm far from an AppleScript expert (and my AppleScript 1-2-3 book is not handy), but what about this idea:
--make sure the outgoing message window is active --have the script send a message to the window to set theWindow to the index of the window --then try the script denoting window theWindow as the front window
But I think the index keyword only works for Finder windows, right? --- mm |