Delete layers using AppleScript

I’m loving the new screenshot features in Acorn 7.4.2 !

One common scenario for me is taking a delayed screenshot with layers and wanting to isolate only a single application. The problem is, if using the “app” or “bundle identifier” directives, the menubar gets omitted. This is a bummer when trying to capture menu items.

So maybe this is an XY problem, but I came up with an AppleScript that almost works. Would love any help getting it the rest of the way there…

set wList to {"Window Server"}
set the end of wList to "Google Chrome" -- just an example

tell application "Acorn"
	screenshot delay 5 with layers
	delay 8 -- need some time for window to appear
	tell front document
		repeat with aLayer in every layer
			set n to (get name of aLayer as string)
			if wList does not contain n then
				log ("deleting " & (get name of aLayer))
				tell aLayer to delete -- this line fails!
			end if
		end repeat
	end tell
end tell

I wish I could answer the AppleScript question - but it’s eluding even me.

I’ll see if I can add the menu bar to it in the next update.


1 Like

Good news - the next release will now include a menu bar when you’re filtering for a specific app. You can try it out right now if you’d like: Latest Builds from Flying Meat

1 Like

That is great news indeed !!