• 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: Paste Reference in OS 10.4
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Paste Reference in OS 10.4


  • Subject: Re: Paste Reference in OS 10.4
  • From: kai <email@hidden>
  • Date: Tue, 8 Nov 2005 18:53:38 +0000


On 6 Nov 2005, at 20:57, I wrote:

set r to the clipboard as record

Seems ill-considered politeness don't really pay - since that crude attempt to preserve the clipboard will error if nothing has been copied since login. Worse, it fails silently when run (as suggested) from the Script Menu. Here's a suitably modified version of the script:


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

property pasteList : {"alias", "Finder reference", "path", "POSIX path", "URL"}
property pasteType : pasteList's item 1


on listToText(l)
	try
		l's t
	on error t
		set tid to text item delimiters
		set text item delimiters to "{"
		set t to t's text from text item 2 to -1
		set text item delimiters to "}"
		set t to t's text 1 thru text item -2
		set text item delimiters to tid
		t
	end try
end listToText

to choosePasteType()
	tell application "Script Editor" to tell (choose from list pasteList ¬
		with prompt "Paste Finder selection as:" default items ¬
		pasteType OK button name "Paste")
		if it is false then error number -128
		set pasteType to item 1
	end tell
end choosePasteType

to convertList(l, c)
	tell choosePasteType() to if it is "alias" then
		repeat with i in l
			set i's contents to i as alias
		end repeat
	else if it is "path" then
		repeat with i in l
			set i's contents to i as Unicode text
		end repeat
	else if it is "POSIX path" then
		repeat with i in l
			set i's contents to (i as Unicode text)'s POSIX path
		end repeat
	else if it is "URL" then
		tell application "Finder" to repeat with i in l
			set i's contents to i's URL
		end repeat
	end if
	if c is 1 then return listToText(l)
	"{" & listToText(l) & "}"
end convertList

to pasteFrom(l)
	set c to count l
	tell application "Script Editor"
		activate
		if c is 0 or (count documents) is 0 then return beep
		if (count (the clipboard)) is 0 then
			set r to ""
		else
			set r to the clipboard as record
		end if
		set the clipboard to my convertList(l, c)
		tell application "System Events" to keystroke "v" using command down
		delay 0.2
		set the clipboard to r
	end tell
	0 -- Script Menu bug workaround (to save script properties)
end pasteFrom

tell application "Finder" to my pasteFrom(selection)

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

---
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: 
 >Paste Reference in OS 10.4 (From: email@hidden)
 >Re: Paste Reference in OS 10.4 (From: kai <email@hidden>)
 >Re: Paste Reference in OS 10.4 (From: deivy petrescu <email@hidden>)
 >Re: Paste Reference in OS 10.4 (From: kai <email@hidden>)

  • Prev by Date: osacompile
  • Next by Date: Re: Logging in all the computers for the little ones.
  • Previous by thread: Re: Paste Reference in OS 10.4
  • Next by thread: Re: Paste Reference in OS 10.4
  • Index(es):
    • Date
    • Thread