I'm having trouble understanding why an AppleScript is required at all, and how it would overcome the delay.
As a test, I wrote a very simple macro that just triggers on change in the Desktop (where I set screenshots to save), then displays that %TriggerValue%
. This macro is still triggering twice, so there are two files created, as before:
However, this macro takes about six seconds to run, so I don't see any way (AppleScript or not) you're going to get around this delay. To make sure the delay isn't something introduced by Keyboard Maestro, I ran this in Terminal before I started the macro:
while true; do
while> ls *Screenshot*
while> sleep 0.5
while> done
The output while running the macro:
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
zsh: no matches found: *Screenshot*
Screenshot 2025-02-13 at 5.02.49 AM.png
Screenshot 2025-02-13 at 5.02.49 AM.png
I ran the macro very soon after starting the little shell script, but even if you call it a second delay, you can see there was quite a bit of time before the file showed up.
Then I disabled the macro, so that only the OS was involved, and the results were identical: There's a long delay before the file shows up. So—AppleScript or no AppleScript—I don't see how this is ever going to run instantly, in terms of letting you very quickly rename a saved screenshot. The delay is at the OS level, not at the Keyboard Maestro level.
Some more testing indicates that the macro isn't even triggered until the small thumbnail of the screenshot vanishes. Only then does the macro kick off, so you can't even put up a "Processing screenshot" message as soon as you trigger the screenshot.
Writing a macro that renames the final file on the Desktop isn't difficult, but I don't see any way to overcome the delay, given it's happening at the OS level. At least not using the folder watching method. I think I can do it another way, though, so I'll post that soon, but do so in a new thread (as it's a different approach completely).
-rob.