PHP Action Plugin


I found keyboard maestro extremely useful, and I think it is quite amazing.

The one action type I did not find was to run an arbitrary PHP script, so I made one.

I chose to convert the parameters and variables to $p{camel case param name} and ${camel case variable name} for convenience (I keep forgetting KMPARAM_ and KMVAR_ , I find them too long).


A prompt for the user with “User Name” becomes: $userName in the script.

The action can accept either a path to a PHP file, or a PHP script , or both … or non if you find it useful … :smile:

I’ve attached my zip file, as well as an example for usage I hope that others will find this useful.

Please let me know if you have any questions about this (or if it does not work for some reason).

Macro Example:

t.php from the macro: (199 Bytes)

The PHP script plugin:
PHP (11.4 KB)


Nice one. Thanks for sharing!


Nice plugin! But what’s the purpose of the ‘Temporary Folder’ variable?


That’s a very good question ! :slight_smile:

I took a closer look at my code, and I actually hard coded /var/tmp in some places , so there is no reason to have that field on the plugin side of things (it will just confuse some people).

I attached a new version that does not need it.

Essentially the script writes a temporary PHP file when entering raw PHP to the text box, and than it executes it, and cleans it when it is done.


PHP (10.4 KB)


ok, this is a new version (yet again), fixed a minor bug …


PHP (10.4 KB)


Ok, thank you for the clarification but the new version no longer works :sob:


Well, it took me a “bit” of time. I retested the script, I am not sure where the issue is.

Just in case, I will re-upload the plugin.

Also, please do not forget to run the following command on your keyboard maestro after re-applying the new plugin:

tell application “Keyboard Maestro” to reload
tell application “Keyboard Maestro Engine” to reload

It is described here:

Please let me know if you still find issues. If you do, please be specific with what you try to achieve.PHP (9.6 KB)


Thank you very much. It works now. I probably forgot to reload Keyboard Maestro the first time. Great plugin!


Is it possible to assign the content of the system clipboard to a variable and process this one via PHP within your plugin? Or are only variables accepted that are entered via a prompt?


Yes, any variable defined in Keyboard Maestro should work with the plugin.


Did you get this sorted?
I’ve done a dump of get_defined_vars() and there is no reference in there to get the current clipboard.
How is this done?


Take a look at this example:

What I do in the example below in keyboard maestro, is to get the content of the clipboard, and assign it to a variable named “test”.

In the PHP script, I am simply “echoing” the variable “$v_test”.

Hopefully that makes more sense.

Let me know