Hi
I tried almost everything to get the icon of a file/folder/app and nothing worked. I wrote about this topic in this forum, but no one had a solution.
I’ve found some ideas to get the icon using objective-c methods. I know that this is not an objective-C forum, but it could be very usefull to all applescript users to know how to get icon of file/folder/app… :oops:
that is what I’m trying, but it doesn’t work. Perhaps anyone could help me!
Icon.h
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
@interface Icon : NSObject
- (NSImage*)getIcon:(NSString *)tmpImagePath;
@end
Icon.m
#import "Icon.h"
@implementation Icon
- (NSImage*)getIcon:(NSString *)tmpImagePath {
NSImage *nodeImage = [[NSWorkspace sharedWorkspace] iconForFile:tmpImagePath];
return nodeImage;
}
@end
AppleScript call:
set a to call method "getIcon:" of class "Icon" with parameter "/Users/yourName/Desktop/AA"
set image of image view "Image" of window "Test" to load image a