Sample Macro

Restart Dropbox When Windows Wakes Up

Written by Kevin Heaton, Insight Software Solutions

What it does

Offers to restart Dropbox when Windows wakes up from sleep mode.

To install

Download the umrestartdropboxwhenwindowswakesup.mex macro file and save it to your hard drive where you store your macro file(s). If desired, import the macro into your existing macro file by clicking File, Import, Import Macros.

To use

Click to tell Windows to go to Sleep. Then press the power button or press a key to wake up Windows. The macro will run when Windows wakes up.

How it works - System Event activation

Windows sends messages when certain events occur. When Windows wakes up from sleep, a WM_POWERBROADCAST message is sent with the message’s wParam set to PBT_APMRESUMEAUTOMATIC. By creating a macro with a System Event activation with these values a macro will run when Windows wakes up.

Macros can be set to run when other system events occur. All that is needed is to find the correct message values for the event. Reference pages document the values for system messages. Message values may be shown in decimal (536) or hexadecimal (0x218) formats, but the system Event macro activation expects decimal values.

The WM_POWERBROADCAST value is 536 decimal and the PBT_APMRESUMEAUTOMATIC value for wParam is 18 decimal. These values are used in this macro to run when Windows wakes up.

How it works - Restart Dropbox

To restart Dropbox the macro first tries to determine if Dropbox is running. It does this by using the Move Mouse to Notification Area Icon command. If the Dropbox icon is found it clicks to stop Dropbox. Then it uses the Program Launch dropbox.exe command along with the /systemstartup parameter to start or restart Dropbox.


This macro may need to be modified to reliably restart Dropbox on your computer.

You may want to perform different actions when Windows wakes up. Modify this macro to remove the commands to restart Dropbox and replace them with your desired actions.


Macro Express Pro