How to replace body contents in Custom HTML Prompt?

I have a very simple test macro, but clearly (after exploring forum and wiki), I'm missing something: I want to replace the entire contents of the <body> section of an HTML document with data stored in a KM variable:

html test window.kmmacros (3.0 KB)

My knowledge of JavaScript is quite limited, but from reading the forums, I thought this was the proper method. However, the test macro simply sits there, not replacing anything.

Help and thanks;

There's an action just for that. Here's an example of how I used it, starting with giving the Custom HTML Prompt window and ID:

<body data-kmwindow="SCREENVISIBLE(Main,Right)-400,SCREEN(Main,Top,10%),320,300" data-kmwindowid="Ingest Window">

That's referenced in the action:

And the div "msg" elsewhere in the window gets replaced with the quoted text in the action.

I’m probably dense, but I’m trying to figure out how to make the bit in your second step reference a KM variable. I can replace all the text just fine with other text, but I don’t know the syntax to use when the replacement text is a KM variable.


Something like this:

document.getElementById('msg').innerHTML = window.KeyboardMaestro.GetVariable( 'LocalVol' );

Perfect, thanks!


1 Like