Set HTML Window Title From KM Variable

Set HTML Window title from KM Variable

Would it be possible to set the window title from a KM Variable?

Countdown Timer.kmmacros (4.1 KB)

Sure, you just set it with JavaScript in the HTML.


function KMInit() {
    document.title =  window.KeyboardMaestro.GetVariable("Whatever");

1 Like

Can the variables be Local or Instance? They don't seem to work. Also, can they be tokens like TriggerValue - can't seem to get that to work either. Of course, I could create global variables and then access them... but that is very clutter-y.


They should work according to @peternlewis:

If you still need help, please post the HTML for your HTML Prompt.

Ok, so I create the html window with this...

And here is my code to update it...

If I remove the Local from the variable name, it works fine. Both Local and Instance prefixes do not work. When used, they clear the text out of the target paragraph, but do not replace it. Running 8.2.4.


Another head scratcher...
If I run these separately, they work fine... but when I combine them in a single macro, the "Write to HTML Window" doesn't run.

I threw a pause in there to see if that helped... nope. Conceptually, I create the html window (that has a table in it) and then use javascript macro to populate the table. It works when you run the macros discreetly, but not when I combine them. What I am I doing wrong?