Have successfully built macro using Custom HTML and really pleased with this feature.
Currently, when I press cancel in the HTML Form, the macro still runs with default values. I would like to cancel/terminate the macro on pressing cancel in the form. I've re-read the manuals, searched the forums and not been able find a solution.
I think the check for "is empty" is probably to check to see if the "Escape" key as used to exit the prompt - I'm not positive.
If you learned anything interesting, please post about it. As you probably know, this is an under-documented feature, mostly because it's HTML which means it can get pretty complex (at least for me).
If you haven't already done so, you might also want to look at this:
(I know this is an old topic, but I ran across this problem yesterday and used Dan's solution, then found Peter's post on the Assert action today and it's another great solution.)
Came across this and saw the last question was not answered. I'll give my answer here in case people will search for it.
First, in the HTML JS code, we put an event listener function here:
function KMInit() {
window.addEventListener("keydown", function (e) {
if (e.keyCode == 13) {
window.KeyboardMaestro.Submit();
}
});
}
Here, keyCode 13 === the "Return" key.
When the "Return" key is pressed, the HTML prompt window will be submitted, and the token %HTMLResult% will be an OK string. We can use this in the following condition action.
If we use @cfriend's approach, we don't need the "OK" string. Mine looks like this:
The %HTMLResult% token (v8+) is set to the the parameter in the Submit() function, and can be used in actions later in this instance like any other text token. The deprecated HTML Result Button variable is also set to the parameter.