• 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: When are we going to be able to get selected text in a Cocoa Application?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >When are we going to be able to get selected text in a Cocoa Application? (From: Michelle Steiner <email@hidden>)

  • Prev by Date: Re: rotate jpeg lossless, wierd
  • Next by Date: RE: Non-character keystrokes
  • Previous by thread: When are we going to be able to get selected text in a Cocoa Application?
  • Next by thread: Re: When are we going to be able to get selected text in a Cocoa Application?
  • Index(es):
    • Date
    • Thread