Hello, I using KM to automate a very long task, running several hours. Is there anyway to have a GUI that’s says like “Start” and “Stop” with some output of specific variables?
I want it to keep running until I click stop, and also print a live log to this GUI, example I could put output to the GUI at specific points in the process.
My backup plan is to try and create some sort of remote GUI where it takes a screenshot every few seconds and I can use remote triggers when I’m not home to control it.
Any help on any of this would be appreciated. Thanks!
As for a live log – I'd use BBEdit and AppleScript the log entries.
--------------------------------------------------------
# Auth: Christopher Stone <scriptmeister@thestoneforge.com>
# dCre: 2023/05/14 18:09
# dMod: 2023/05/14 18:09
# Appl: BBEdit, Keyboard Maestro Engine
# Task: Write Log Entries to a Named Text Document.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Keyboard_Maestro_Engine, @Write, @Log, @Entries, @Named, @Document
--------------------------------------------------------
set kmInstance to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
set logEntry to getvariable "local_LogEntry" instance kmInstance
end tell
set logEntry to "Now is the time for all good men to come to the aid of their country."
logToBBEdit(logEntry, "LOG")
--------------------------------------------------------
--» HANDLERS
--------------------------------------------------------
on logToBBEdit(logEntry, windowName)
tell application "BBEdit"
tell text window windowName's text
set end of it to logEntry & linefeed
end tell
end tell
end logToBBEdit
--------------------------------------------------------
I recommend BBEdit because…
Although BBEdit is a commercial product, the trial version reverts to a
still very powerful and free (BBEdit-Lite) version after 30 days.
It is very Mac-like.
It has excellent support for RegEx.
It is very AppleScriptable.
It has a two versatile command line tools.
It has been in continuous development for over 25 years.
You could use CotEditor (freeware) instead, but it's not nearly as powerful as BBEdit.
So I'm really new to KM, like 2 days into this. Lets start with the log, because this seems like a nice way to see what going on, almost like a debugger. While I'm new to KM, I have been a developer for over 20 years (PHP).
I used a Run AppleScript action, pasted your code, BBEdit did open up. but nothing else happened, and the script didn't continue to run. Not sure if I'm doing something wrong. Thanks for for your help!
Hi Joah,
You might want to have a look at my Checkpoint System utility for KM which allows you to do this sort of thing. It was primarily created to assist with debugging macros, but it can also be used for simply tracing/logging a running macro in real time. You can see details of it here
Another very powerful utility, created by @_jims might also be of help. You can read about it here