KM Last execution date

In AppleScript there are numerous items against each macro, creationdate, modificationdate etc.

It would be handy if the last run date was stored in there too making it simpler to use than parsing the plist file.

I agree. @peternlewis, could you please add "last run date" to the properties of macros exposed in AppleScript.

Thanks.

You could always include a step in the macro setting the variable to the current date. The variable would then be available to AppleScript.

We're not looking for the current date, we're want the LAST RUN date.
IAC, it is very easy to get the current date directly in AppleScript.

Noted.

Not sure if that was intended as a reply to me, but unless I'm missing something, each time (after the first) the macro is run, the variable would initially contain the last run date, which was the current date when it was last run. That could be used in the macro for whatever purpose the OP had in mind. Then at the end of the macro, the variable could be reset to the new current date and stored for next time.

As. The OP I would like what I said, an extra property with the last execution date. It’s hardly a massive overhead, the data is available in the plist so it is a very minor task to add it as an extra property as stated.

Yes I could mess about with variables, I could parse the plist, I could parse the log file, I could write it down in a notebook and then type it in manually. I would, if possible and not too much effort, prefer an extra property.

:wink:

As a workaround, it's not a bad idea, but it does not come close to providing the last run date as an AppleScript Macro property. For example, I might want to get a list of all Macros last run during some date range.

See: inessential: This Feature Should Be Easy

General rule: when asking for a feature, do not explain how easy the feature would be to implement.

More general rule: when asking for help, do not explain how little effort it will require to provide the help.

This feature request is on the todo list.

And it may be. Or it may not. It may be that that data is stored in some dynamic location that is not easily accessible from the required section of code. It may be that it requires use of some tech that is not safely usable at that point. Or it may be that to access that data requires transitioning through threads or structures that are hard or impossible to access at the point it is required. Honestly, I have no idea, and wont know until I try to implement it.

I do know that “last execution date” handling is way, way more complicated than anyone would expect. For example, at one point there was a special Keyboard Maestro Last Executed.journal file just for dealing with the complexities of tracking that while the editor is not running, and without modifying the macro file, but making it available to the editor when necessary. It was also stored in the Keyboard Maestro Last Executed.plist file. Now it is stored in the Keyboard Maestro Macro Stats.plist which has an entire file devoted to controlling access to it, sharing data around, reporting changes, and what not. Maybe it has sufficient support for access from the AppleScript property subsystem, maybe not.

Almost always, things are a lot more complicated than would generally be expected - this is in part why computer software is generally so buggy, and has so many edge cases and weird behaviours.

Just close it, I will do without.

Peter, as a general rule, I agree. And the OP did NOT suggest how easy/hard it would be to implement in the OP:

But now that we have all be lectured about what NOT to ask for, I'm sure it will never happen again. :wink:

As a developer myself, I can say this:

  • Sometimes it turns out to be much harder than you expect.
  • Sometimes it turns out to be much easier than you expect.

For me, letting a "hard" problem bounce around in my head overnight, or a few days, sometimes results in a solution easier to implement that I originally thought.

Finally, it is always better to promise long and deliver early than the other way around. :wink:

IAC, I still would like to have the "last run date" property for a Macro in the Scripting model.

Since Peter has already told us it is on his list of feature requests, I think we can let it rest there. :smile:

Done for the next version.

  • Added last used AppleScript properties for macros
2 Likes