Using Firefox (or any other browser) to load KM Variables with user prompts

Some of you might benefit from a (hopefully easy to follow and customize) example of how to use Firefox (or any other browser) to input KM variables.

KM's Custom HTML Prompt is quite powerful, but it has some shortcomings. For example, dropdowns aren't invoked with a down-arrow, autofocus does not work, and neither does using Tab to simultaneously choose from a dropdown then advance to the next input. Firefox, on the other hand, allows me to autofocus whichever form input I want. Also, in Firefox, once I use arrow keys to make my choice for an input (like a dropdown), hitting Tab will select that choice and advance to the next input (saving me a Return stroke for each input). I often use HTML to prompt for input of variables that I use in various KM macros, so I wrote the following macro to allow for Firefox to render the HTML. Javascript (within the HTML file) collects the variables, then the KM macro retrieves the variables.

There are a couple of preliminary steps you'll need to take:

  1. Create the GenericBrowserFormForKM.html file (described in the macro's first action, in red), and save it to your machine. Once you get the macro running, you can customize the HTML file to your particular needs, but keep it as is for a demonstration.)
  2. Correct the path names in the macro actions to point to your copy of GenericBrowserFormForKM.html. Do this by replacing the ~TheParticularPathForWhereYouSavedTheFile part of the path.

Browser-based KM Variable Loader Macro (v9.0.5)

Browser-based KM Variable Loader.kmmacros (44 KB)

Once you get this running in Firefox, try opening the HTML file with Safari to notice how many more keystrokes are needed in Safari (and other browsers) to navigate the inputs, compared to Firefox.


I forgot to mention that the macro is set up to wait for the \ key. When it is pressed, KM will automatically close the page and process the variables.

@thoffman666 - Very helpful - thank you

I’m glad it’s useful for someone other than me.

Perhaps it is how you design the KM HTML Prompt.
Here's a great example by @DanThomas:
Bootstrap 3 + Auto-Complete HTML Prompt Example

I don't see most of those issues in Dan's macro.

For me, the real power of the KM HTML Prompt, that can't be duplicated by a stand-alone HTML file, is the tight integration with KM Variables, as Dan shows:

  1. Initialize form fields with KM Variables
  2. Populate form field selection data with KM Variables
  3. Auto save the user entires to KM Variables.

Dan’s macros are great, but as I’ve pointed out in several other posts, his macro is too slow to be of use to me when I have to live-search large files. It bogs down for about three seconds per keystroke while it searches. With my own HTML pages, I routinely live-search to choose from a document that has nearly a half million characters making up a list of over a thousand choices that are about four hundred characters in length each, and there is no perceptible lag.

We don't need to rehash that debate here. But just for a complete, balanced picture of Dan's Macros, I have found them very fast, with no lags, even when I am doing a search for 2,000+ lines. It has been noted that you have an exceptional use case. I'm glad you have found a solution for you that works.

I agree that we don't need to rehash it. And if there is anyone else out there who needs a tool that does NOT bog down (for at least half a million characters), then you might want to consider my solution.