Chapter 2. Scripting the Scheduler

Example 2.1. Start the Scheduler

Start the Scheduler queuing and performing events.

tell application "Power Manager"
    tell Scheduler to set enabled to true
end tell

Example 2.2. Stop the Scheduler

Stop the Scheduler. Stops events being queued and performed.

tell application "Power Manager"
    tell Scheduler to set enabled to false
end tell

Example 2.3. Toggle the Scheduler's State

Toggle the Scheduler's start/stop state.

  • If the Scheduler is running, stop performing Events.

  • If the Scheduler is stopped, start performing Events.

tell application "Power Manager"
    tell Scheduler to set enabled to (not enabled)
end tell

Example 2.4. Name of the Next Event

Get the name of the next Event to trigger.

tell application "Power Manager"
    tell Scheduler
        set myName to name of event of first queued trigger
    end tell
end tell

Example 2.5. Actions of the Next Event

Get the action classes of the next event to trigger.

tell application "Power Manager"
    tell Scheduler
        set actionClasses to class of actions of event of first queued trigger
    end tell
end tell

Example 2.6. Date and Time of the Next Trigger

Get the trigger date of the next event to trigger.

tell application "Power Manager"
    tell Scheduler
        set nextTriggerDate to date of trigger of first queued trigger
    end tell
end tell

Example 2.7. Delay a pending trigger

Delay the next pending trigger by 5 minutes.

tell application "Power Manager"
    tell Scheduler
        
        -- Get the next trigger
        set myTrigger to first queued trigger
        set myDate to date of trigger of myTrigger
        
        -- Delay by 5 minutes
        adjust trigger with id (id of myTrigger) to date (myDate + 300)
        
    end tell
end tell

Example 2.8. Cancel an Event

Cancels the next pending Event.

tell application "Power Manager"
    
    tell Scheduler to cancel trigger with id (id of first queued trigger)
    
end tell