Re: Text Selection in Mail.app
Re: Text Selection in Mail.app
- Subject: Re: Text Selection in Mail.app
- From: <email@hidden>
- Date: Wed, 14 Jan 2004 17:40:56 -0500
Well, it's pretty much impossible. If you really want to preserve the=20
clipboard contents, it's trivial to wrap this in a handler.
on getMailSelection()
set lastClip to the clipboard as record
tell application "Mail" to activate
tell application "System Events"
tell application process "Mail"
click menu item "Copy" of menu "Edit" of menu =
bar 1
end tell
end tell
delay 1
set newClip to the clipboard
set the clipboard to lastClip
return newClip
end getMailSelection
Note that you have to get the clipboard contents as a record to=20
preserve all the representations that are available on the clipboard.=20
Honestly, there are problems with this method too. If there is only
one=20=
representation, it should work correctly, but some apps may
improperly=20=
select a simpler type on the pasteboard. An example may be
necessary=20
here:
=95 Control-click on a name bubble in Mail.app and copy it
=95 Run the following applescript:
set x to the clipboard as record
set the clipboard to x
return x
=95 You should see three representations the clipboard has for that =
object
=95 Paste it back into a mail.app address field
Normally, if you copy an address bubble in mail and paste it into an=20
address field, it comes up as a bubble, but in this case it pastes=20
text, then pauses for a little, and then updates it into a bubble.=20
Other applications can be worse. OmniOutliner pastes gibberish if
you=20
copy lines and try to paste them back in after filtering them through=20
applescript. Some data put on the clipboard causes this script not
even=20=
to run, such as an iChat Buddy List entry. To cover this case you=20
should wrap it in a try block and catch error -1700.
Usually, things work out fine if you're pasting into a different=20
application, it's just the same one that has problems. The problem is=20
either that programs select the wrong representation from the list,=20
applescript short-circuits special handling the applications have for=20
their own data types, or that applescript isn't putting the data back=20
on the clipboard in exactly the same way. We have no interface to
the=20
clipboard except getting, setting, and the ever so useless "clipboard=20
info" command, so we have no way of fixing these issues.
Unfortunately, perfection is impossible.
BJ
On Jan 13, 2004, at 11:26 PM, Walter Ian Kaye wrote:
>
>
Uhh... *without* touching the clipboard?
_______________________________________________
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.