How to suspend a virtual machine using AppleScript (when hibernating the Mac)? I need an application, which will:


Activate Parallels Desktop
While holding Opt, select 'Actions > Suspend'
Activate SmartSleep
Minimize SmartSleep
Click 'Hibernate' of menu item 'QuickSleep' of menu
After resuming the Mac, resume vm also.


Here is my try:

    tell application "Parallels Desktop" to activate
    tell application "System Events"
        tell process "Parallels Desktop"
            click menu 1 of menu item 5 of menu
            delay 1
            tell application "System Events" to keystroke option
            delay 1
        end tell
    end tell
Sleep/wake cannot trigger scripts. EventScripts, although it is a very impressive program. it not fit this purpose it does NOT actually appear to be able to trigger scripts quickly enough before your Mac goes to sleep.

but there are many third party solutions. For example,  sleepwatcher