This works fine but only for an unpredictable number of iterations (I've seen 20 iterations work and later I've seen 150 work). Eventually it fails with the following errors. Any ideas as to why this fails? Thanks.
The "CompileAppleScript string failed" is most probably talking about an AppleScript within an action within the executed macro, rather than the AppleScript shown in Hazel (note that the AppleScript is probably being used implicitly by Keyboard Maestro rather than an Execute AppleScript action, eg something like the SystemVolume token, which uses AppleScript to retrieve the value.
My guess would be the system running out of process ids, caused by too many executions of the CompileAppleScript tool in quick succession. (CompileAppleScript is a tool that Keyboard Maestro uses to execute AppleScript outside of the Keyboard Maestro Engine process to avoid the crashes that AppleScript periodically causes).
Peter, in that case, is it correct that you would NOT have to use the CompileAppleScript tool with a .scpt file, since it is already compiled? If so, the user could use a script from file with the Execute AppleScript Action.
No, Compile executes the AppleScript as well, it performs a variety of different internal AppleScript features for Keyboard Maestro related to off-boarding the AppleScript interaction to avoid crashes in AppleScript taking out the engine or editor.
I run a very long-time macro everyday, which sequentially execute other macros. It usually should take about 1.5 hours to finish all Execute Macro actions. And I found the whole keyboard maestro engine always freezes until I touch the Mac manually. Today it froze again, I looked at the Mac carefully. I touched the trackpad and it started to simulate scroll wheel, so I am pretty sure this issue happened during the opening web action group and may before simulate scrolling or simulate scroll itself. But I am not sure which action is related to Apple Script. Maybe Simulate Scroll Wheel?
It's so hard to reproduce. Only after running macro for long time, and it will appear somewhere in the middle. I have no idea which action it straightly relates in sure.
Background Information:
MacBook Air (13-inch, Mid 2013)
macOS Version 11.1 (20C69)
RAM 4 GB 1600 MHz DDR3
(an old Mac using as a "server" at home)
Keyboard Maestro Version 9.2