Input in Custom HTML Prompt: How to select the default input string by default?

Hi,
My purpose is:

  1. Let the Custom HTML Prompt get the saved variable value and put it in the "Input" box as the default input.
  2. Highlight this default input, so that I may start typing immediately, replacing the default input.

I'm stuck at step 2.
For now, I use the "Execute a macro" Asynchronously action to type the "Tab" key to accomplish it. But I want to be able to do it with javascript without executing another macro asynchronously.

Is it possible?

I tried the element.select() function in KMInit(). It does not work.

Here is my test code:

    <html>
    <head>
	<script>
    function KMInit() {
        document.getElementById("myid").select();
    }
	</script>
    </head>
    <body>
            <div><input type="text" id="myid" name="LocalName" autofocus/></div>
    </body>
    </html>

I have a "set variable value" action before the Custom HTML Prompt to simulate the default input value:
image

My goal is to automatically highlight the "default input" string:
image

But now, it looks like this:
image

Oops...
As soon as I posted it, I've found the solution myself. It is to put the element.select() function in KMDidShowWindow():

    <html>
    <head>
	<script>
    function KMDidShowWindow(){
        document.getElementById("myid").select();
    }
	</script>
    </head>
    <body>
            <div><input type="text" id="myid" name="LocalName" autofocus/></div>
    </body>
    </html>
1 Like