• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: get selected text of message in Mail?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: get selected text of message in Mail?


  • Subject: Re: get selected text of message in Mail?
  • From: kai <email@hidden>
  • Date: Mon, 31 Jul 2006 00:02:35 +0100


On 28 Jul 2006, at 17:06, Michelle Steiner wrote:

An old message on this subject came up with this, among other, solutions for this problem.
activate application "Mail"
tell application "System Events"
tell process "Mail"
get value of attribute "AXSelectedText" of text area 1 of scroll
area 2 of splitter group 1 of window 1
end tell
end tell

However, this works only on incoming messages in the three panel view. It does not work if the message is displayed in its own window, nor in an outgoing message.


Does anyone have any suggestions for a universal solution, or at least one for an outgoing message?

It's a fairly simple matter to extract selected text from incoming messages (however they're displayed), Michelle - but not quite so trivial where outgoing messages are concerned. The only workaround I'm aware of goes something like this:


-----------

on selected_Mail_text()
activate application "Mail"
tell application "System Events" to tell application process "Mail"
set current_target to window 1
tell current_target's splitter group 1 to if exists then set current_target to it
tell attribute "AXSelectedText" of text area 1 of current_target's scroll area -1 to if exists then return value
tell menu item "Copy" of menu "Edit" of menu bar item "Edit" of menu bar 1
(* or, for greater portability: tell menu item 5 of menu 1 of menu bar item 4 of menu bar 1 *)
if not enabled then return ""
set current_clipboard to the clipboard as record
set the clipboard to {}
click
repeat while (the clipboard) is {}
delay 0.1
end repeat
set selected_text to the clipboard
set the clipboard to current_clipboard
end tell
end tell
selected_text
end selected_Mail_text


selected_Mail_text()

-----------

---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: get selected text of message in Mail?
      • From: Michelle Steiner <email@hidden>
References: 
 >Re: get selected text of message in Mail? (From: Michelle Steiner <email@hidden>)

  • Prev by Date: Re: Scripting Finder window column widths
  • Next by Date: Re: (OT) FileMaker Web Viewer
  • Previous by thread: Re: get selected text of message in Mail?
  • Next by thread: Re: get selected text of message in Mail?
  • Index(es):
    • Date
    • Thread