• 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: Copy text to the clipboard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Copy text to the clipboard


  • Subject: Re: Copy text to the clipboard
  • From: kai <email@hidden>
  • Date: Mon, 5 Dec 2005 20:49:23 +0000


On 5 Dec 2005, at 19:47, John R. wrote:

On Dec 5, 2005, at 1:50 PM, kai wrote:
Either of my earlier suggestions (scpt or app) work fine for me (10.4.3):
What happened when you tried them?

Thank you, kai, for pointing me right to the earlier posting. I had overlooked it. Works great. Appreciate the help. For example, a useful little "Quote This" menu script as follows:


set appName to (info for (path to frontmost application))'s short name
tell application "System Events"
    set process appName's frontmost to true
    keystroke "c" using command down
    set the clipboard to "\"" & (the clipboard) & "\""
    keystroke "v" using command down
end tell

Right. For more accurate quoting in certain situations (if, for example, the selected text is destined for an AppleScript 'display dialog' command), you might want to consider something that treats existing backslashes and quotation marks appropriately:


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

on quoted_text(t)
	set d to text item delimiters
	repeat with c in {"\\", "\""}
		set text item delimiters to c
		set t to t's text items
		set text item delimiters to "\\" & c
		tell t to set t to beginning & ({""} & rest)
	end repeat
	set text item delimiters to d
	"\"" & t & "\""
end quoted_text

set appName to (info for (path to frontmost application))'s short name
tell application "System Events"
	set process appName's frontmost to true
	keystroke "c" using command down
	set the clipboard to my quoted_text(the clipboard)
	keystroke "v" using command down
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
  • Follow-Ups:
    • Re: Copy text to the clipboard
      • From: kai <email@hidden>
References: 
 >Re: Copy text to the clipboard (From: "John R." <email@hidden>)
 >Re: Copy text to the clipboard (From: kai <email@hidden>)
 >Re: Copy text to the clipboard (From: "John R." <email@hidden>)

  • Prev by Date: Re: Copy text to the clipboard
  • Next by Date: Re: Copy text to the clipboard
  • Previous by thread: Re: Copy text to the clipboard
  • Next by thread: Re: Copy text to the clipboard
  • Index(es):
    • Date
    • Thread