Auto Arrange Multiple KM HTML Prompt Windows?

I'm looking for a way to…

  1. find all KB HTML Prompt windows that are open,
  2. depending on their number, arrange them in a grid.

Background:

I built myself a tool where I can dictate ideas or letters on my phone, and then have them pop up on my desktop computer. The transcription is managed by a web server (using Google Cloud), and it then calls a KM macro on my computer using the Public Web Trigger, in order to display the results right on my screen. This way, when I come back to my desk, I'll have the text on there.

I'm using HTML prompts instead of "Display Text" windows, because I can have the HTML prompts appear like colored notes. This way, it looks like a bunch of colored sticky notes on my screen, and they are "always on top".

However, right now, KM will open each prompt on top of the other.

What I would like instead is:

  1. Pre-define an area of my screen allotted to such notes,
  2. Then divide this space among all open HTML Prompts.

That means, the first prompt will fill the entire space. Once a second prompt opens, the first prompt will be resized to 50 %, and the second one will open at 50 %, at an offset of 50 %.

It should look like this:

I imagine that the solution would be perhaps an AppleScript. It would be called whenever a new prompt is opened, and it would count all open prompts and then re-arrange them, so that all are visible and distributed evenly within the allotted screen space.

The Execute a JavaScript in Custom Prompt action will let you run JavaScript is all the different Custom HTML Prompts. So, for example, you could set a variable to 0, and then use the action to execute a script in each custom prompt, each of which triggered a macro to increment a variable. Then you'd know how many there were. But then you'd have to ask each to move to a specific location, and it's more difficult to identify them. It could likely be done, but it would be somewhat convoluted. Probably you need each of them to have some sort of unique ID (they could just pick a random large digit number).