IntelliMacro Scheduler

Introduction

IntelliMacro Scheduler is a background program that can run macros automatically when specific events occur. A lot of different events are supported: Running a macro when a hotkey is pressed or at a specific time of day is the most obvious example, but maybe you want to run a macro when a process is started, a window appears or disappears, the system is low on battery power or a file was created/deleted by another program? All of this is possible with IntelliMacro Scheduler. You may use any plugins for IntelliMacro in the scheduler as well.

Unfortunately, this flexibility has drawbacks as well. Most notably, setting up a macro is considerably more complex than with similar, less flexible solutions. In addition, a poorly configured scheduler task can draw a considerable amount of CPU cycles even when it is inactive. On the other hand, when you got into using this scheduler, you might not want to use any other (less flexible) scheduler any longer. Please also bear in mind that I primarily wrote this scheduler for my own use (which is quite common for open source projects), so if you have ideas of how to improve it, feel free to write me.

Setting up the scheduler

Copy a shortcut to it to your Startup folder and you are done. Mostly. Maybe you want to carry the scheduler around on your USB pen drive? In that case, you can create a ScheduledTasks folder inside your application directory, and all your tasks will be stored there. If you do not have such a folder, your tasks will be stored in your user-specific ApplicationData folder, so make sure to back that one up if you want to keep your scheduled tasks.

The scheduler will run in the system tray. Double-click the icon to open it. Here you can disable the scheduler completely, and add, edit, remove or enable/disable individual tasks.

The poll interval specifies how often tasks will be checked that need polling (i. e. that cannot detect themselves that their condition became true). You can increase this if your tasks need too much idle CPU time. When none of your active tasks needs polling, a label (polling disabled) is shown below the poll interval input box.

In case that the scheduler crashes, you can just reload it from the start menu. If, for some reason, the crash was caused by one of your tasks, you can hold the Scroll Lock key while loading the scheduler, which will disable all tasks temporarily so that you can fix them. Pressing and holding the Scroll Lock key will also abort any tasks that are currently running.

Anatomy of a Scheduler Task

Every task consists of three parts: Initialization, Condition and Action.

Initialization

This macro is executed when the scheduler starts or the task is edited. It can be used to initialize variables that are needed for the condition or the action. It is also executed after the action when the reinitialize variable is set to 1. Every task has his own macro variables; these variables are cleared before (re-)initialization.

Condition

There are different kinds of conditions:

None
This task will never be run. This is useful for tasks that are unfinished or which do all they need in their initialization part (like a task that has to be performed at scheduler start only).
Event
Events are actions that are triggered from "outside". The most well-known example are hotkeys, but there are other events available as well, like battery power events or filesystem events. Events are builtin IntelliMacro functions (like RegisterHotkey that return a special kind of object, a MacroEvent. As events are triggered from outside, they do not require polling when enabled.
To create a hotkey event, use an event expression like RegisterHotkey(<Shift>,<F11>).
Condition
Conditions require polling. Just write any macro expression into the condition field; it will be evaluated whenever the task is polled, and the action is run if the result is nonzero. A special variable pollcount is available in the condition, which is incremented after every polling. If your condition is more complex than a macro expression, or if it takes some time to evaluate, you might consider using a condition like pollcount % 10 = 0 and add the real condition as an Uf condition to your action macro. If the reinitialize condition is set and nonzero after polling (and maybe executing the action), the initialization part is run again. This can be used to reinitialize variables when needed.
Time
Time functions require polling as well, but the polling is very quick since the current time must only be compared by a NextTime timestamp. The entered formula should return a timestamp in .NET Ticks. The action will be executed (and the timestamp reevaluated) after that timestamp. Usually, this timestamp is produced by the GetDate function, but you can write your own plugin function or macro to calculate them if more complex conditions are needed.

Action

The action is a simple macro that does what you have to do in that task. Note that the variables are shared with the initialization macro and are not cleared after every execution.