• 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: How to copy the icon of a selected item
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to copy the icon of a selected item


  • Subject: Re: How to copy the icon of a selected item
  • From: Christopher Stone <email@hidden>
  • Date: Thu, 26 Jan 2012 10:18:09 -0600

On Jan 26, 2012, at 09:37, Barry Fass-Holmes wrote:
The following script, which is intended to copy a selected item's icon (folder or file) and is based upon the script at http://hints.macworld.com/article.php?story=20091111215845472, returns an error.

set newIcon to selection as alias
tell application "Finder"
activate
set infoWindow to open information window of newIcon
set infoWindowName to name of infoWindow
end tell

tell application "System Events"
tell application process "Finder"
tell window infoWindowName
keystroke tab
delay 1
keystroke "c" using command down
close infoWindow
end tell
end tell
end tell
______________________________________________________________________

Hey Barry,

In the above script 'selection' is useless.  You're telling Applescript to get the 'selection', and although it compiles it doesn't know what you're talking about.  'selection' in this case is a property of the Finder.

Here's a working version of the script above along with some error-checking:

------------------------------------------------------------------------------------------------
try
tell application "Finder"
activate
set theFile to selection as alias list
if length of theFile = 1 then
set theFile to item 1 of theFile
set infoWindow to open information window of theFile
set infoWindowName to name of infoWindow
tell application "System Events"
tell application process "Finder"
tell window infoWindowName
keystroke tab
delay 0.1
keystroke "c" using command down
end tell
end tell
end tell
close infoWindow
else
error "Something is wrong with the selection!"
end if
end tell
on error errMsg number errNum
set {cr, sep} to {return, "------------------------------------------"}
set e to sep & cr & "Error: " & errMsg & cr & sep & cr & "Error Number: " & errNum & cr & sep
beep
display dialog e
end try
------------------------------------------------------------------------------------------------

--
Best Regards,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >How to copy the icon of a selected item (From: Barry Fass-Holmes <email@hidden>)

  • Prev by Date: Need infos about Final Cut Pro X
  • Next by Date: Re: How to copy the icon of a selected item
  • Previous by thread: How to copy the icon of a selected item
  • Next by thread: Re: How to copy the icon of a selected item
  • Index(es):
    • Date
    • Thread