Trigger notification if macro is not running

I have a macro that automatically runs every 6 seconds.

I also have a macro that temporarily turns the first macro off to execute and then turns it back on if it is not. But, sometimes the turned off macro doesn't actually get turned back on.

I would like to create a trigger for a macro to test if it is running several times a minute.

Is there a trigger that would test if a macro is running, so I could notify the user to make a decision to activate the macro or not.

Please post your macros.

I run a macro that takes screenshots of two computer monitors every six seconds. I later convert the screenshots into a video and review it to make sure I have an accurate accounting of the time I spent during the day.

When I try to perform copy and paste, the screenshot gets pasted and not the item I copied. My workaround has been to create a macro to replace the copy command. The macro begins with a Quit All Macros function before the copying takes place. I also replaced the paste command with a macro that pastes the content that is on the clipboard and starts the screenshot macro. The problem is that sometimes I look up and see that the screenshot macro is not running. I would to create a macro that tests the idle status of a specified macro at predetermined intervals and then lets me know that it is not running and provides a user prompt to snooze the alerts, and start or cancel the screenshot macro.

I've created an image describing what I would like to happen, but the trigger type doesn't exist, I could not fully test it.

Pasted_Image_4_29_22__11_57_AM

Could you try using a named clipboard for the screen caps to stop it conflicting with the system clipboard?

This, for starters. Alternatively write the screenshot directly to a file and then, at the end of the day, you'll have a folder full of files ready to be converted to your video.

Is your screen cap macro constantly running, a simple loop with pauses built in? There's an AppleScript query to find out if a macro is running but, obviously, you'd have to run that from outside of KM! ~I can't find an environment variable that lists currently running macros, but maybe someone will step in here...~

A-n-d I've found it myself -- you need to get %ExecutingInstances%, which you can then convert to a collection and iterate through the UIDs to find the names, testing those against the name of the macro you want to check for. Consider this a placeholder while I knock up a PoC...

Another option might be to think different. If your screenshot macro wrote files to a folder, you could regularly check when the last file was added -- check every minute and, if the last file was added more than a minute ago, alert the user.

1 Like

I haven't learned Applescript yet. I know it is incredibly powerful, but just haven't had the time.

That being said, the macro I have been using while trying to figure this out does save the screenshots to a folder, so I really like the idea of checking the modification date of the last screenshot taken to see how long it has been. I'll give it a shot.

No AppleScript required for any of this (I should have struck through that bit as well).

When you write a new screenshot to the folder, the folder's "Modification Date" will update. You can get that with a "Get File Attribute" action (which works on folders too) into eg the variable "Local_lastMod" and then %Calculate%NOW() - Local_lastMod% will give you the time in seconds since the last screenshot arrived.