Is there a way to get the data from an Applescript image (AXImage), perhaps using Applescript/Obj-C?

22 Views Asked by At

Hi there — I’m writing an Applescript that uses System Events to get an image:

tell application “System Events”
    tell process “appName”
        tell window 1
            set theImage to image 1
        end tell
    end tell
end tell

The variable theImage is now an AXImage, but there’s no function in UI Scripting to get the raw data from that object. I know that using Foundation/Obj-C, I could use the TIFFRepresentation method, but I don’t understand how (or even if it’s possible) to cast an AXImage to an NSImage.

Does anyone have any clues?

I’ve tried various alloc/init combinations, but none seem to work. NSImage doesn’t have an imageWithImage method either — it seems to either require you have a URL or you already have the data. I could use NSObject’s copy, but I don’t understand how I would use that in the above script either.

0

There are 0 best solutions below