If you need to detect variable value changes from inside a Custom HTML prompt action, it may be useful to notice that in addition to:
window.KeyboardMaestro.GetVariable( 'KMVariableName' )
(which yields an up-to-date copy of the Variable value, at the the time of code evaluation)
you additionally have access, through document.kmvar
, to a frozen snapshot of the Variable values, as they were at the moment that the Custom HTML Prompt first launched
This means that you can detect changes by comparing the two results:
-
document.kmvar
(values at launch) -
window.KeyboardMaestro.GetVariable
(values now)
For example this yields the following divergence of values, over time, for a KM Variable called localTemp
: