Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Copy text to the clipboard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Copy text to the clipboard




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
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>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.