Hey all
How do I go about getting the icon for any given application via applescript?
Any suggestions greatly appreciated!
Thanks
D
Hey all
How do I go about getting the icon for any given application via applescript?
Any suggestions greatly appreciated!
Thanks
D
Hi,
if the programmers have followed Apple’s guidelines, e.g.
set iTunesIcon to path to resource "iTunes.icns" in bundle (path to application "iTunes")
Thanks mate. I will give that try now.
Hi Joy, You’ll find a lot of info here too. MacScripter topic: Icons in display dialog…
http://macscripter.net/viewtopic.php?id=16489
Regards,
Tom
Browser: Safari 531.9
Operating System: Mac OS X (10.6)
This one works for me on just about any bundled item:
(*
This script will try to find the name of the default icon in any bundled file (application, prefpane, etc.) by reading the appropriate key in the bundle's plist file. Icon's name is not *always* the bundle's name plus ".icns"
Simply select the bundled item in the finder and run the script.
*)
tell application "Finder"
set TheApp to (selection as string)
try
-- First, test for a bundle by trying to set the path to the Contents folder...
set ResPath to (TheApp & ":Contents:Resources:") as alias
on error
-- Ooops! Not a bundle!
beep
display dialog (name of (TheApp as alias)) & " is not a bundle" buttons {"Okay"} giving up after 6
return
end try
set theFile to TheApp & ":contents:info" as string
--".plist" extension on "info.plist" isn't needed.
set theFile to quoted form of POSIX path of theFile
try
set iconName to (do shell script "defaults read " & theFile & " CFBundleIconFile")
--tries to read the name of the default icon from the bundle's plist file.
on error
beep
display dialog "There is no default icon for " & (name of (TheApp as alias)) & "." buttons {"Okay"}
return
end try
if iconName does not contain ".icns" then set iconName to iconName & ".icns"
--plist key sometimes includes extension; if not, add it.
set the clipboard to ResPath & iconName as string
display dialog "\"" & ResPath & iconName & "\"" & return & return & "is on the clipboard" buttons {"Okay"} --giving up after 6
end tell
Anyone know how to put a custom icon in front of the warning sign like icon 2 does with an application tell, with an icon not owned by an app.
This is only possible in ObjC unless you use a custom icon you’ve created