How to test if Custom HTML Prompt is already open

I have an asynchronous custom HTML prompt that displays a value when a MIDI message comes in and then the window automatically goes away after 1 second. But, if another MIDI message comes in while the HTML prompt is already displayed, I want to update the value displayed in the prompt and reset the timeout back to 1 second.

I have a macro that either a) creates the prompt window or b) calls "Execute a JavaScript in Custom HTML Prompt" to fetch and display the most recent value. I want to wrap a) and b) in an IF action to determine which to call. Everything I have tried results in a stack of HTML windows being displayed on top of one another until each one successively goes away as their timeouts expire.

I just need to know what condition to test for in the IF action of my macro so I don't keep creating brand new prompt windows when a perfectly-good window already exists.

Your IF action can check the Text %LastWindowID% for a value over 0 to confirm the existence of the HTML Window if that's the last one in your action. You can also check the %WindowName% if it has a title.

Thanx. I had already tried testing for %LastWindowID% and I couldn't get it to work.

I think the reason is explained by Peter here.

The window creation has to be asynchronous in order to test for LastWindowID. But, because the interval between calls is so brief (less than 0.5 sec), the window hasn't had a chance to be created yet. So by the time the next instance of the macro is called, the previous instance hasn't obtained a window ID yet and the IF condition fails.

BTW, my Custom HTML Prompt is a transparent, frameless, HUD with no title, so I can't check for a title. The HUD is just supposed to pop up in the corner of the display whenever the mixer's Main audio level changes and display its value briefly then go away.

1 Like

Use a semaphore lock so your instances are run sequentially, one at a time. Set a variable to %LastWindowID% before you put up a new HTML Prompt, then a "Pause until..." after the prompt action to hold until %LastWindowID% is not equal to the stored ID.


Yeah, using the semaphore did the trick. Thanx.

I had it in there before, but somehow deleted it and didn't notice.