in Automation, Life&Travels

Text management with Keyboard Maestro

In the new release of Keyboard Maestro (v.7.0) a bunch of new features were added to the already incredible application.

One of the most interesting to me is the “Custom HTML Prompt” which let’s you create custom prompts using HTML code and Javascript.

So I decided to integrate my Text Management Tool written in Javascript with KeyboardMaestro, to be able to access it with just an hotkey.

Then I decided to go further and automatically get the content of my system clipboard when it displays, and send beck to the clipboard when I close the window.

Here you can find the action.

And this is a screenshot of the “Custom HTML Prompt” in action.

TextManager

How does it works?

It works very easily: you have only to write an HTML page and modify the body in this way:

<body data-kmwindow="SCREEN(Main,Left,20%),SCREEN(Main,Top,20%),1024,585">

That’s all. It tells KeyboardMaestro where to place the window and the width and height of the same.

Then in the code I use custom KeyboardMaestro object to get the clipboard into my text field:

document.getElementById('mytext').value = window.KeyboardMaestro.GetVariable( 'TextClip')

And last but not least, to make the button “COPY TO CLIPBOARD” work copying to clipboard and closing the form:

case "toclipboard":
	window.KeyboardMaestro.SetVariable( 'TextClip', text );
	window.KeyboardMaestro.Submit();
	break;