Screen capture by AREA issues

I'm liking the new macro that allows making a screen capture of an area, but I can NOT get it to work the way I need it to.

If I do a screen capture (with/without Keyboard Maestro) using the "shift/cmd/4" key combination, then followed by "spacebar", it creates a screenshot of the clicked application window and saves it to my defined folder for all screenshots, using my defined format of "Screen Shot 2022-11-03 at 11.07.34.png". This format ensures that there is never a duplicate filename (provided there is always at least one second between captures.

This method, in Keyboard Maestro, works exactly as I would expect it to. The disadvantage is that the capture includes the entire application window, in which case I need to later crop every image to remove the unwanted areas of the app, leaving only the desired inner area. I would expect the new "Screen Capture by Area" to perform in exactly the same manor... but it does not. The best I can do is capture the desired area and then saving it to a predefined file name.

Is there a way to make the "Screen Capture by Area" ("shift/cmd/4", followed by the defined area coordinates) perform in the same manor as ("shift/cmd/4", followed by "spacebar" & click) which automatically saves to my predefined Screenshots folder, using my predefined naming convention... WITHOUT need to add in a "write to file" action which simply overwrites each previously created image?

I'm not sure which bit is the problem -- is it just the "saving the file with the correct file name" part? In which case, this will grab the front window of the active app and save it with your preferred name format in a folder on the Desktop called "Screenshots" (set the trigger to suit your preference):

Screenshot Front Window.kmmacros (2.3 KB)


I've used "front window" in the example instead of "area" because you don't say how you are getting the values for the area selection -- if that's the bit you are having trouble with then post your macro and say how you'd like to select the area to screenshot.

That does look like the solution, Nigel_S... THANK YOU!

My problem was that I was not using the coded format for the creation date. When I run the macro using Shft-Cmd-4, followed by Space and Click, it automatically uses the System's defined folder and format for the PNG. I'm not sure why the Area Select method works any differently. But I have no doubt your solution will work. It's been a while since I've worked with KM and it's grown a lot since then. This is the section that I used to use. (The Right Arrow simply flips to the next page.)

Probably because in the macro you've posted you are using the OS's Screen Capture utility which, by default, saves to the Desktop with the name formatted as you stated. The KM "Screen Capture" action is different and always captures to a clipboard which you then need to write to a file of your choice.

There do seem to be some other, subtle, differences too. If you want to use the OS Screen Capture utility from within a KM macro you can use an "Execute Shell Script" action that calls screencapture -- you can see the various command line options by typing man screencapture in Terminal.