I have an AppleScript that when run within FileMaker it either is a hard crash or looks like a hard crash.
Is there a way of using Apple Script to run a Keyboard Maestro macro asynchronously?
Cheers and thanks!
Keith
I have an AppleScript that when run within FileMaker it either is a hard crash or looks like a hard crash.
Is there a way of using Apple Script to run a Keyboard Maestro macro asynchronously?
Cheers and thanks!
Keith
At the top of every macro is a phrase that says "or by script". If you change that option using the arrow buttons you can change the phrase to "or by AppleScript." That will show you the code that you need to use AppleScript to run a KM macro. Of course, the KM Engine has to be running for that to work.
I'm not very fluent in AppleScript, but I don't think the language definition for it allows for any asynchronous code within the definition of the language directly. Therefore, you have to look for solutions using the application that is executing the AppleScript that you want to run. If you insist on using the Filemaker app to run the AppleScript to execute the KM macro, then you are limited by the Filemaker app's support for asynchronousness. However if you can get Filemaker to spawn a shell, specifically an asynchronous shell, then you should be able to use that feature to spawn a shell that runs the osascript command which can call AppleScript to execute a KM macro, as I mentioned in the first paragraph above.
So you should check to see if Filemaker can spawn an asynchronous shell. I asked ChatGPT if Filmaker can do this, and it said yes. So perhaps you should check its manual.
Even though I don’t have FileMaker it’s relatively simple to do…
Link the Execute a Macro Action to the desired Macro, turn on the asynchronous option and copy it as XML to the clipboard.
From there you’re able to use the Macro Action‘s XML in your FileMaker AppleScript Automation by calling the KM Engine and use the XML in KM‘s do script command leaving everything off the XML Code behind that comes before <array>
and after </array>
.
Greetings from Germany
Tobias
Wow, that's a cool approach.
Thanks @Airy and Tobias @Nr.5-need_input
Neat approach. I especially like seeing I can turn off the TimeOutAbortsMacro.
— ignoring application responses
tell application "Keyboard Maestro Engine"
do script "<dict>
<key>ActionUID</key>
<integer>1233</integer>
<key>Asynchronously</key>
<true/>
<key>MacroActionType</key>
<string>ExecuteMacro</string>
<key>MacroUID</key>
<string>D7069387-9D4F-436B-B2B3-C26F3B5A0020</string>
<key>TimeOutAbortsMacro</key>
<true/>
<key>UseParameter</key>
<false/>
</dict>"
end tell
— end ignoring
I discovered that ignoring application responses
can also be used to make the AppleScript call asynchronous.
Greetings from Australia
Cheers and thanks!
Keith
Ah, that’s what that is for! Of course.