I need infos. I try in many way to copy an icon to the clipboard and I always an unknown content. I take my informations from the Finder dictionnary. You have a porpertym, “icon family” but they don’t take any of my command. (Ex. large 8 bit icon) I always got an error.
Can you help me?
I just need an example of a script where you copy an icon (an example where you copy to clipboard and another to a variable) from an application and paste it to another application.
Thank you!
Thank you for your answer. But why you have a fonction for icons in the Finder? I can’t believe you can’t do something without an addition of a scripting addition. Maybe someone can explain me the “icon family” in the Finder dictionnary. (This is in Type Definitions/icon family, check too in Window classes/information window/icon) If someone can tell me what is the fonctions of all this, I will really appreciate. Thank you in advance!!
Hello, Frédéric.
You don’t need to use the clipboard to copy an icon from one file to another:
tell application "Finder"
set icon of file thisFile to icon of file thatFile
end tell
If you do want to use the clipboard, the Finder must be the frontmost application while its commands are accessing the clipboard:
tell application "Finder"
activate -- bring the Finder to the front
set the clipboard to icon of file thisFile -- don't omit the "the"
set the icon of file thatFile to the clipboard -- don't omit the "the"
end tell
An ‘icon family’ contains six different bitmaps for an icon, allowing it to be displayed in the different sizes allowed by the Finder’s ‘View Options…’, in colour or in black and white. (I have one application that shows completely different icons, depending on which icon size I set in the folder window.)
Hope this helps.
NG
Thank you very very much! This help me alot!!!
I don’t believe this is a simple script. =)
Frédéric
While it appears the “icon family” is pasted to the clipboard, it does not appear to be pasting to the second file (thatFile) in the above script.
When I copy an icon manually through a file’s information window, the icon appears in the clipboard as a “picture”. I could paste this to any file.
When I used the above script and viewed the Finder’s clipboard I saw no visible represenation and it’s data type was “unknown”. I could not paste this information.
Akua Sweets also seems to not work even though its dictionary implies it has this capability.
Any suggestions?
Andrew Yaeger
You’re right! Different data get put on the clipboard, depending on the method used. These seem to be references to the icon at different levels. Using the ‘clipboard info’ command from Jon’s Commands to examine the clipboard contents in each case, I get (with all tests in a ‘tell’ block which activates the Finder):
set the clipboard to icon of file "About ResEdit 2.1.3"
get clipboard info
--> {{reference, 152}}
set fred to icon of file "About ResEdit 2.1.3"
set the clipboard to fred
get clipboard info
--> {{icon family, 2320}}
-- Copy the icon manually
get clipboard info
--> {{«class icns», 2296}, {large monochrome icon and mask, 256}, {large 8 bit icon, 1024}, {small monochrome icon and mask, 64}, {small 8 bit icon, 256}, {picture, 2732}, {reference, 84}}
If you have Sändi's Additions, you can automate the manual process (as it were) like this:
tell application "Finder"
activate -- bring the Finder to the front
open the information window of file thisFile
TypeText tab with Shift -- back-tab to the icon with Shift-tab
TypeText "c" with Command -- copy with Command-C
close the front window
end tell
This puts the icon on the clipboard as a picture that can be pasted manually.
NG
Very killer Nigel
Ray~