Automated 5:30 AM Screenshot?


My goal is to have KM go to a specific webpage at 5:30 every morning, take a screenshot, and then save it. In a perfect world, it would be saved to a folder not a clipboard.

Is there a reason the following is not working, and also any tips for how to get screenshots saved to a folder instead of a folder?

The macro in the screenshot does open the correct webpage, but it never takes a screen shot.

Many thanks for any help!

Keyboard Maestro can only operate when the Mac is awake, and the Mac is probably asleep at 5:30am. So no macros will run at that time.

You can configure the System Preferences, Energy Saver, to wake your Mac at 5:29.

But then you'll get the next problem, which is that the screen will be asleep or screen saving or screen locked, which will stop any UI actions from working (the Open URL action will probably work, but the Wait For action relies on menu access, and that may fail, and then screen capture will almost certainly fail).

So you'll have to also use the Wake Screen action, and the Stop Screen Saver action. And if you have a password on your Mac screensaver, that will not be possible either (since the password would be required to unlock the screen).

So this will likely prove challenging.

Thank you @peternlewis! At least now I know not to keep trying!

1 Like

Don't give up right away @Gregg_Stebben :wink:

With the Power Manager software you can create the following action:


I can use the action shown to wake my Mac at a certain time and then log in using the built-in KM macro AppleScript.

You can then perform your desired action/workflow and then retire the Mac.


Well, to answer your second question: the best way (IMO) to get a screenshot saved to a folder is to use a shell script with the built-in command screencapture like so:

screencapture -x -t "$FORMAT" "$FILE"

where $FORMAT is something like jpg and $FILE is the name of the file you want to use.

However, as you've seen, getting a screenshot when your Mac is locked is a problem. That's why we need a different tool.


wkhtmltopdf and wkhtmltoimage are open source (LGPLv3) command line tools to render HTML into PDF and various image formats using the Qt WebKit rendering engine. These run entirely "headless" and do not require a display or display service.

Download the macOS installer. Note that you will have to right-click » Open to bypass gatekeeper, as the package isn't "signed" which poses a risk if the program contains malware. All I can tell you is that I have done so and suffered no ill fate. YMMV, Use at your own risk, etc.

Here's an example of how to use wkhtmltoimage to make a JPG of a recent blog post that I wrote:

wkhtmltoimage \
--format jpg \ \
"$HOME/Desktop/A Place for Everything.jpg"

So, now the question is, how do we set this up to save with a new filename every day in a folder that you designate?

Something like this should work, I think:

You can put that right into Keyboard Maestro as a shell script.

You will need to customize at least one line of the file:


As I doubt you really want ABC's homepage.

Also you may want to change this:


to the name of whatever folder you want to use. It will be created if it does not exist.

Filenames will be something like this:


For 12:54:03 a.m. on August 7th, 2021.

That can also be adjusted if needed. Just let me know and I can tell you how to tweak it.

Feel free to ask questions if you have them!


Thank you for this @appleianer ...I didn't even know Power Manager existed...that is great for all kinds of things!

1 Like

Thank you so much @tjluoma I can't wait to try this!!

1 Like

@Gregg_Stebben until 18 months ago I also knew nothing about this software :wink:
If you want the macro above to unlock the Mac/MBP, please get in touch.

Power Manager is a great tool that is not very well known.

1 Like

@tjluoma I agree with you on that.

@Gregg_Stebben I came across this because I wanted an alert about the battery status (30%, 10% etc.) of my MBP that also works when it is closed.

The trigger should be similar to the automation in the Shortcuts app.

In conjunction with a notification via the Pushover app, I receive the respective battery level on
all  devices.
Even when I am on the road :wink:

Copied Image

On my MBP, as well as my iMac, I have also set up a Time Trigger via Power Manager that alerts me to the Battery state at a certain time.

Here is an example for my iMac:


I transferred the KM macro shown into the Power Manager app via the KM macro AppleScript.

I think there's going to be a totally new way to solve this problem in macOS Monterey. The Shortcuts app allows you to take screenshots and (at least in iOS, so far) it also allows Shortcuts to be scheduled to run at 5:30am each day. You can save the screenshot in a folder, too. In the current Monterey Beta the Automation tab is missing, but it's reasonable to guess that Apple will bring this feature to macOS.

There's also another way to solve this using only internal macOS commands. I'll skip the details, but you can execute commands like this:

pmset repeat wakeorpoweron MTWRFSU 05:30:00 sleep MTWRFSU 20:00:00

I just created a Keyboard Maestro macro for this exact situation. I needed to take a screenshot of my Robinhood account page everyday at 6 pm.

To address the issue of the Mac waking up I use Power Manager which @tjluoma mentioned. Other important tools include:

I'll share the macro tomorrow and I've made a YouTube video about the automation that is still uploading.

@tjluoma, How do you set the time to take the screenshot? Do you use the Time of Day trigger in KM? Also, how does your script rename a file? In my workflow, I use the TextExpander action available for Keyboard Maestro then, when Hazel spots that name it moves it to a specified folder.

Yes I would suggest time of day in keyboard maestro.

My script uniquely named the files with the current time in the script itself so it doesn’t need to be renamed.

Thank you everyone for digging deep into this...I am looking forward to putting this to work for my situation, too!