• 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: Fri, 2 Sep 2005 15:00:37 +0100


On 2 Sep 2005, at 12:00, Gary (Lists) wrote:

"kai" wrote:

On 2 Sep 2005, at 10:03, Gary (Lists) wrote:

Well, I liked the "preserve the original clipboard" politeness in
Kai's
script, and obviously Martin's is shorter and speedy.

- and doesn't touch the clipboard. :-)

Yes, yes. I meant that I wanted it on the clipboard, and that I'd also like
to preserve it, as you did. Hence the marriage.

Yeah - neat combination, Gary. (I was only pointing out a further benefit of Martin's approach in the context of the original question.) :-)


================

On 2 Sep 2005, at 11:24, Martin Orpen wrote:

On 2 Sep 2005, at 11:04, kai wrote:

However, I'm now getting inconsistencies here, too - so I think my 'Enable GUI Scripting' question (which I realise was far too basic an oversight for Martin anyway) was a red herring. Needs a little more investigation...

Yeah - I'm outraged that you'd made that suggestion :-)

I've already donned the sackcloth and ashes, Martin. ;-)

I've solved the G5 problem:

tell application "System Events"
tell process "Mail"
get value of attribute "AXSelectedText" of text area 2 of scroll area 2 of splitter group 1 of window 1
end tell
end tell


For some reason Mail on my Powerbook has the selection in "text area 1" and the G5s have the selection in "text area 2".

There might be a way to cater for either possibility. I was also looking at the structural differences between a message window and a message viewer window with something like:


----------------

tell application "System Events" to tell process "Mail" to tell window 1
try
value of attribute "AXSelectedText" of text area -1 of scroll area -1 of splitter group -1
on error
try
value of attribute "AXSelectedText" of text area 1 of scroll area 1
on error
""
end try
end try
end tell


----------------

However, that still doesn't cope with the window of an outgoing message - or with HTML messages, for example.

(Incidentally, I was tinkering with ways to avoid a try block by determining if a message viewer is frontmost. Best I could come up with was <tell application "Mail" to set viewerFrontmost to id of window 1 is in id of windows of message viewers>.)

================

On 2 Sep 2005, at 12:49, Martin Orpen wrote:

I've noticed something limiting about "AXSelectedText" - it can't handle multiple selections.

So, if you are in the habit of command-clicking over multiple selections of text you'll need to use Kai's script.

I see that <value of attribute "AXSelectedTextRange"> also returns a simple, two item list based on the start and end character positions of the first text selection only. Oh well...


---
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
References: 
 >Re: get selected text of message in Mail? (From: "Gary (Lists)" <email@hidden>)

  • Prev by Date: Re: turn on Remote Apple Events remotely?
  • Next by Date: Re: Translating XML SOAP terms to AppleScript?
  • Previous by thread: Re: get selected text of message in Mail?
  • Next by thread: what is Image Capture Scripting?
  • Index(es):
    • Date
    • Thread