Has anyone written a macro using the Custom HTML action that can display a table of values, sort of like a spreadsheet does?
It would be very helpful if the grid supported "header titles" at the top, and even better if it let me sort the table by clicking on the headers.
And then, ideally, it would let me double click on a cell (or on a column or a row) which would return the value(s) to the calling macro. (Although I'm not sure how it would inform the calling macro that the data being returned is a row or a column. Maybe it can return a JSON string?)
I'm not very adept with HTML code, especially if it involves Javascript, but I possibly could try to tackle this if nobody else has done so yet.
Wikipedia has built in support for this sort of thing (so it's definitely possible.) Here's an example:
You can read about its full support here:
I want to avoid calling the app Numbers and filling it with data. But that's always an option if I can't get this idea working with a Custom HTML action.
I'm pretty sure you can't do exactly what you want without JavaScript code. Writing the HTML is simple—there are HTML/CSS table generators, or any of the LLMs are quite good at it if you describe the table you want to create. "Build me an HTML/CSS table with this row as table headers:.... and these as my data rows...and make it styled like this, etc."
They do a very good job of this.
The challenge is getting the data back out. The Custom HTML Prompt was really designed as an input form, where you'd fill in a data field, click OK, and the data would come back to Keyboard Maestro. You can sort of usurp that in a stupid way:
Click a button, and you get back to Keyboard Maestro, for example, data#dogs#65. But I am 99.9992% convinced this isn't what you want or need. I just wanted to show how to get data out of a Custom HTML Prompt without Javascript.
For what you're describing, I think you'll need a JavaScript that's watching for clicks on values in cells. And you'd have to run your prompt asynchronously, if you wanted it to stay open. And I have no experience with that, in terms of getting back data in real time while the form is still onscreen.
Sorry if this isn't much help, but wanted to share the little I knew about getting data back out of a form. I might also ask what you're trying to accomplish—perhaps that might open up some other methods of accomplishing the goal?
Indeed, I did try an LLM, and got some interesting results (which do include javascript.)
I think I can launch the Custom HTML form asynchronously, and then as soon as the form changes the clipboard, by placing the data into the clipboard, the KM Engine can detect the change, close the form, and that's how I get data "back." That's my plan. I seem to be close to getting this working.