Change KM Defaults Such as Pause Until Timeout, Failure Aborts Macro toggle, etc

If there's a way, I missed it. I searched the forums but kept finding the same question I had and "there's no way" answers from before KM 9.

Is there a way--a native KM option or a macro someone has created--to change some of the KM default toggles and settings for various actions?

For instance, I'm doing a lot of Pause Until Found Image actions lately, and the default timeout is 99 Hours, which has been causing me some problems I had contacted @peternlewis about . I'd like to change the default to something more reasonable like 30 Seconds. Then, every Pause Until Found Image action I create will use that by default instead of 99 Hours.

I'd also like to be able to (maybe) toggle Restore Mouse Location to on in Click At Found Image actions, or to toggle Notify on Failure off as the default. I'm sure there are others I'd like to change, too.

Is there a way to do this in KM 9.1?

1 Like

What I and many other KM users do for this is use the KMFAM utility macro:

1 Like

@iampariah, highly recommend it. I use it almost every day.

1 Like

Hey Pariah,

Sure you can – here's an example:

Keyboard Maestro “Paste Dated Attribution Action v1.0” Macro

It's unlikely Peter will ever add this functionality – because demand is not all that high, and it'd be complicated to do.

However – our intrepid and talented friend @DanThomas who was a software engineer in another life built KMFAM for this very purpose.

KMFAM is an outstanding piece of work – is quite comprehensive – is free – and is pretty turnkey.

Only a few folks have had much trouble installing it, and I believe Dan has been able to help all of them overcome their issues.

I would recommend this option, before you even consider trying to roll-your-own.

If you do decide to build your own mousetrap then you can use my macro above as an example.

To create your own custom actions you have to manually create the action with all your custom attributes and then copy it as XML.

My macro shows how to use that XML to create a new action – although its not completely straightforward, since it's part of a purpose-built macro.

If there's more interest I'll post a more basic example.

You can also create template macros in Keyboard Maestro with one template action each and use a Prompt With List action to insert them into the working macro.

I'm working on a proof-of-concept for this right now, but it's poor man's fare compared to KMFAM.


1 Like

Hi Chris (@ccstone), I've been looking at your idea of creating custom actions for a project of mine based on your Keyboard Maestro Editor ⇢ Paste Dated Attribution Action v5.00 Macro

Your macro creates the new action at the start of the target macro using the AppleScript statement

set newAction to make new action with properties {name:"Macro Notes", xml:attributionActionXML} at beginning

(which is exactly where you need the attribution to be placed.)

What I'm after is to insert the new action just after the currently-selected action in whatever macro I'm editing. I've tried leaving off the

at beginning

but that just puts the new action at the end of the macro. I've searched high and low through the AppleScript documentation for how I might achieve this but with no success. Is there anything you could suggest? :pray:

Hey @tiffle,

Unfortunately Apple's AppleScript documentation is mediocre and incomplete.

It's also impossible for Apple to document how AppleScript works and quirks in all the various AppleScriptable applications.

Software developers also drop the ball by not documenting how their own software works.

Appended is a script that demonstrates what you want to do.


Insert an Action ⇢ Compiled (13.4 KB)

Insert an Action ⇢ AppleScript Source Text
# Auth: Christopher Stone
# dCre: 2021/01/08 06:46
# dMod: 2021/01/08 06:46 
# Appl: Keyboard Maestro
# Task: Insert an Action After the Selected Action OR at end of Actions.
# Libs: None
# Osax: None
# Tags: @Applescript, @ccstone, @Script, @Keyboard_Maestro, @Insert, @Action, @After, @Selected
# Vers: 1.00b01

   • This script will work as is – it contains a handler with a KM Action's XML.
   • The script demonstrates how to add an action AFTER the selected action
     OR at the END of the actions in the working macro – IF no action is
property actionName : "DEBUG -- Display Variable in Window and Cancel Macro"

tell application "Keyboard Maestro"
   --» Get first selected macro.
   set firstSelectedMacro to first item of (get selected macros)
   --» Get selected item.
   set selectionList to selection
   if length of selectionList > 0 then
      set {selectedItem} to selectionList
      if class of selectedItem = action then
         tell firstSelectedMacro
            set newAction to make new action with properties {name:actionName, xml:getSavedActionXML() of me} at after selectedItem
            select newAction
         end tell
         tell firstSelectedMacro
            set newAction to make new action with properties {name:actionName, xml:getSavedActionXML() of me} at after its last action
            select newAction
         end tell
      end if
   end if
end tell

on getSavedActionXML()
   set newActionXML to text 2 thru -1 of "
    <string>DEBUG -- Display Variable in Window and Cancel Macro</string>
   return newActionXML
end getSavedActionXML
1 Like

I can see why it's impossible to provide documentation covering the plethora of scriptable apps and, having once been a software developer, I know how easy it is to leave the documentation until the end when often there is not the will nor the budget to complete it!

So I'm really grateful that you have answered my query so expertly and so quickly. Thanks :+1: :+1: :+1:

If you want to learn more about AppleScript then drop by the Late Night Software forum.

They have the highest density of AppleScript experts and traffic on the web these days.

Also – if you haven't bought Script Debugger then at least use Script Debugger Lite (free). It puts Apple's little Script to shame.

Mark Alldritt who operates the LNS Forum is also the developer of Script Debugger, and he has taken over care of as well.


Well, this is probably the only time I can say “l’m ahead of you”! I bought a full license for SD quite some time ago and it has been invaluable as I’ve been progressing with my AppleScript journey. However, given my patchy understanding of AppleScript I find it difficult sometimes to understand/interpret what it is that SD is actually showing me. I haven’t made much use of the LNS forum which I can see now is a mistake on my part.

Anyway - thanks for the pointers and generous help. It’s most appreciated.

1 Like