Re: When are we going to be able to get selected text in a Cocoa Application?
Re: When are we going to be able to get selected text in a Cocoa Application?
- Subject: Re: When are we going to be able to get selected text in a Cocoa Application?
- From: kai <email@hidden>
- Date: Sun, 8 May 2005 03:47:01 +0100
On Friday, May 6, 2005, at 04:29 pm, Michelle Steiner wrote:
It's frustrating not to be able to get selected text in a cocoa
application, or at least in mail.app. I need this ability to be able
to write a simple script to create a .sig from a text snippet in a
message.
-- Michelle
tell application "mail"
set selText to the selected text
-- obviously, the above line does not work now
display dialog "What is the name of the new .sig?" default answer ""
set sigName to the text returned of the result
make new signature at end of signatures with properties {name:
sigName, content: selText}
end tell
It does seem to be a rather glaring omission, Michelle.
In the meantime, I suppose we could always resort to a little
UI/clipboard subterfuge...
-------------
tell application "Mail"
activate
set clipStore to the clipboard
set the clipboard to ""
tell application "System Events" to keystroke "c" using command down
set selText to the clipboard
set the clipboard to clipStore
try
if (count selText) is 0 then return
on error
return beep
end try
set sigName to text returned of (display dialog ¬
"What is the name of the new .sig?" default answer selText's
paragraph 1)
make new signature at end of signatures with properties {name:sigName,
content:selText}
end tell
-------------
---
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