Keyboard Maestro and JSX


Is there a way to execute and/or interact with JSX scripts? I would like to use Keyboard Maestro variables within JSX scripts inside Adobe Illustrator, Adobe Photoshop or Adobe InDesign.


I use the approach from below to run a javascript in InDesign with KM Variables.

So I write the javascript-file with the KM variables and then tells InDesign to execute this javascript-file.

I do not know if the same could be applied to Photoshop or Illustrator.

Keyboard Maestro “Run javascript in InDesign with KM Variables” Macro

Run javascript in InDesign with KM Variables.kmmacros (3.5 KB)

Hey Jimmy,

This looks like a neat idea! But, is it not too slow?

It is not slow in my experience.
But I have not used it that much for anything else, than updating links, which this macro does.
And then exporting pdf-files automatical from a list of filenames.

Here is a working sample, which creates a new document in InDesign with a text frame.
The user inputs the text for the text frame with KM.

And it works pretty fast.

Keyboard Maestro “Run javascript in InDesign with KM Variables (working)” Macro

Run javascript in InDesign with KM Variables (working).kmmacros (3.8 KB)

1 Like

Thank you very much Jimmy! I will explore the possibilities but it looks very promising…

If you do make some cool things, then please share if you deem they can be used by others.

There is no need for a Pause there - the file is fully written before the action continues, and the next action is a script which references the file, so it’s just adding a 1 second delay unless there is something else involved.

I will remove the pause and test. I think I made it just as a precaution to make sure the file was written.

Hi @JimmyHartington,

So, after a few weeks, here is my first experiment.

I regularly have to reduce a frame and its content to an exact size in InDesign documents. To do that, I have to type an exact dimension with its unit in the Percent Scale fields. I also have to select the correct Reference Point and the X or Y coordinates. When I have to repeat this operation on multiple frames, it quickly becomes boring. Especially that, sometimes, I need to type the dimensions in millimeters, other times in points, depending of the ruler unit.

This is why I wanted to use an HTML Prompt and Keyboard Maestro variables within InDesign.

The HTML Prompt is also an experiment. It almost exclusively uses SVG and jQuery:

Then, using the Keyboard Maestro variables, a JSX file is written and executed by InDesign as you suggested.

Here is the macro:

Scale Object in InDesign.kmmacros (35.3 KB)

I provide it as is.

I'm looking forward for your comments.


This works fine on my machine.
But I wonder if this is easier accomplished using InDesigns native toolpalette.
Maybe a KM macro to activate the correct field.
But you maybe have looked into this.
It is a nice HTML Prompt you have made.

Indeed, I previously made a macro that actually allowed me to check the native correct Reference Point, to activate the X or Y Percent Scale fields and to type the value but, sometimes, it did not work as it should. And it was a bit slow. The script is more reliable and fast. Trust me, when you have to adjust tens of frames, it’s very effective :smiley:

1 Like

Also, there's nothing like the joy of using something cool you created yourself, right? :slight_smile:

Right! :+1:

Just found this topic, this looks amazing!
@carycrusiau, I wonder, why did you go with KB+HTML prompt instead of proper CEP-panel for ID? I think you made 90% of the job for a native panel.
I use KM+OSA+JSX for instance to select specific vector tools in PS:

1 Like

Because I do not know anything about CEP-panel :thinking:
Can you give me some explanations? I'm more than interested!
I'm also interested by some other examples of what you do with KM+OSA+JSX.

CEP HTML/JSX panels are custom extensions for CC: these were flash-based panels in pre-CC era. That's probably a good starting point:

The idea basically is that you have an HTML + JS for GUI (and whatever JS libraries you want to use on the panel), JSX for Photoshop side and Adobe JS library 'CS Interface' to communicate between them.
Here's an example of the panel I did for Photoshop recently:

And what you've done in KM HTML-prompt can be a separate extension that'll work on both OSX/Win.

As for KM+OSA+JS, I do it like this:
I have a KM variable that refers to a folder or a specific jsx file like in this example:

Then in OSA script I tell Photoshop to
do javascript (file referenceToJSXFromKMVariable) with arguments {"my_argument"}

And in jsx I have a function that selects a specific vector tool based on argument I'm getting from OSA

1 Like

Thanks Sergey! Looks interesting. I will study the possibilities closely.

I was trying to run this macro and was getting an error with the script ran. It seems KM is auto-replacing the double-quotes which errors out the Javascript. How do I prevent that?


I think you need to turn of typograhic qoutes in settings before you import the macro.

1 Like