Copyright: Sean Cross


Contents
Scheduler: Contents

Scheduler is a macro based scheduling program.  It allows the execution of user defined commands at specified times.  Commands are available to Start and Stop programs, Send keystrokes to windows and give messages to the user.

Possible uses include starting an offline newsreader during the middle of the night to download files (the original reason for creating this program), scheduling unattended backups of data or acting as an alarm clock to remind you when 'Friends' is on.

Anyway, get to it.

Further help is available on the following topics:

Usage:

Running Scheduler

Editing Schedules

Editing Macros

Select Window Dialog

Tutorials:

Tutorial 1: Notepad

Tutorial 2: Agent

Macro Commands:

ActivateWindow

CloseWindow

Delay

Execute

MessageBox

SendKeys

SendKeysClass

SendKeysWindow

Bugs:

Known Bugs

Scheduler is a freeware program.  However all money, gifts, alcohol or (more likely) postcards will be gratefully accepted.

Copyright 1996 Sean Cross


Running Scheduler

Scheduler can be started by double clicking on the icon (No! Really?).  This brings up the start window.

Once scheduler is running, all scheduled items will be executed at the appropriate time.

From version 1.3 onwards, scheduler can be started with a command line parameter specifying a macro.  Scheduler will then run the relevant macro and close.  Eg

  C:\schedule\schedule.exe Test

will load and run the macro named test before quitting.  This allows you to run complex tasks on an as required basis rather than on a scheduled basis.  For instance, I use this to start winsock, download my newsgroups and check my mail while I put the coffee on.


Editing Schedules

The schedule editor is available by pressing the Edit button on the Start Screen.  The editor is shown below:

Items can be created and removed using the 'Add Item' and 'Delete Item'.  They can be reordered by dragging to a new position within the Scheduled Items box.

Editing is performed by clicking on an item.  The item can then be changed using the Item Info edit boxes.  Items will be automatically ordered.

Macros can be edited by clicking on the 'Macros' button.

Pressing OK will accept and save any changes.  Pressing Cancel will discard changes and reload the schedule from disk.


Editing Macros

A macro consists of a list of commands which are carried out automatically by the scheduler.  The macro editor is invoked by pressing 'Macros' in the Schedule Editor window.  The macro window is shown below.

 A macro is selected for editing using the macro combo box.  Macros can be created and destroyed using the 'Add Macro' and 'Delete Macro' buttons.

Once a macro has been selected, the Macro Items list is enabled.  Items can be added or removed using the 'Add Item' and 'Delete Item' buttons.  An item can be reordered by dragging to a new position.

Selecting an item by clicking on it with the mouse enables the Command Info boxes.  A command is chosen using the Command combo boxes, and the arguments entered below.  The browse buttons '...' will assist in entering arguments.  Once an item or macro has been entered, it can be tried using the Test buttons.

The 'Rem' button will temorarily disable (indicated by a '>') and then enable a macro item.

The available commands are:

ActivateWindow

CloseWindow

Delay

Execute

MessageBox

SendKeys

SendKeysClass

SendKeysWindow

WaitForModemIdle


ActivateWindow

Usage:	ActivateWindow	Class Name	Window Title

ActivateWindow finds and activates a window.  This brings the window to the front and means that SendKeys commands will affect the named window.  Only one of the two arguments is needed, and wherever possible Class Name should be used in preference as the class name for a given window remains constant.  Use the browse buttons ('...') to select Classes and Titles.

Eg ActivateWindow 'Notepad', '' will activate the Notepad window as it has a class name of 'Notepad'.  ActivateWindow '','Readme.txt - Notepad' will activate the Notepad window only if the window title is 'Readme.txt - Notepad'. I.e. if a file called 'readme.txt' has been loaded.


CloseWindow

Usage:	CloseWindow	Class Name	Window Title

CloseWindow finds and closes a window.  If this is the main window for a program then this will also closed the program.  However some programs will open a message box asking for confirmation before the program can be closed.  In these cases a further CloseWindow  or Sendkeys command should be used.

Only one of the two arguments is needed, and wherever possible Class Name should be used in preference to Window Title as the class name for a given window remains constant.  Use the browse buttons ('...') to select Classes and Titles.

Eg CloseWindow 'Notepad', '' will close the Notepad window as it has a class name of 'Notepad'.  CloseWindow '','Readme.txt - Notepad' will close the Notepad window only if the window title is 'Readme.txt - Notepad'. I.e. if a file called 'readme.txt' has been loaded.


Delay

Usage:	Delay	Seconds

Pauses execution of the macro for the supplied number of seconds.  This may be used to allow an Executed program to open before sending commands with SendKeys.

Eg Delay 20.5 will delay execution of the macro for 20.5 seconds.


Execute

Usage:	Execute	Filename 	Path 	Parameters

Finds and opens the supplied program or file.  If a data file is supplied then the associated program will be opened.  Path specifies the starting directory for the program.  Parameters refers to further command line parameters that may be required.

Eg 	Execute Notepad will run Notepad, while Execute A:\ReadMe.Txt will open the file ReadMe.Txt using the default text editor.

Execute Notepad C:\  will run Notepad, with the initial directory being C:\.

Execute Notepad C:\ autoexec.bat  will run Notepad, with the initial directory being C:\, and open the file autoexec.bat for editing.


MessageBox

Usage:	MessageBox	Message

Displays a dialog box with a message.  Eg MessageBox 'I love rock and roll, so put another dime in the jukebox baby' will produce the following dialog.


SendKeys

Usage:	Sendkeys	Key String

Sendkeys will send the key string to the active window.  This has the same effect as typing the key string on the keyboard.

Eg  Sendkeys 'I do like to be beside the seaside'  will produce the same effect as typing  'I do like to be beside the seaside' on the keyboard.  As no window has been specified, whatever window is currently active will receive the keystrokes.  Whenever possible use SendKeysClass command instead.


SendKeysClass

Usage:	SendKeysClass Class Name	Key String

SendKeysClass will activate the named window and send the key string to that window.  This has the same effect as selecting the window and then typing the key string on the keyboard.

Eg  SendKeysClass 'Notepad', 'I do like to be beside the seaside'  will produce the same effect as selecting the Notepad window and typing  'I do like to be beside the seaside' on the keyboard.

Use SendKeysClass in preference to SendKeys or SendKeysWindow.


SendKeysWindow

Usage:	SendKeysWindow Window Title	Key String

SendKeysClass will activate the named window and send the key string to that window.  This has the same effect as selecting the window and then typing the key string on the keyboard.

Eg  SendKeysClass 'Readme.txt - Notepad', 'I do like to be beside the seaside'  will produce the same effect as selecting the Notepad window and typing  'I do like to be beside the seaside' on the keyboard.  However this will only work if the window title is 'Readme.txt - Notepad'. I.e. if a file called 'readme.txt' has been loaded.

Whenever possible use SendKeysClass command instead.


WaitForModemIdle

Usage:	WaitForModemIdle Comm Port, Idle Seconds, Max Seconds

WaitForModemIdle waits until the modem on port no. Comm Port is idle for Idle Seconds.  If the port does not become idle then the command finnishes after Max Seconds.  While running, this command displays the following window:

Resting the mouse over a led will display the function it is monitoring.  Right clicking on a led will enable changing the comm port.

Eg WaitForModemIdle 3, 8, 1000 waits until the modem on Com3 is idle for 8 seconds.

Usage notes:

•	Setting Idle Seconds to a high value and clicking Test Item will allow you to check modem activity and ensure that the correct comm port is being monitored.

•	Some modem programs send messages periodically over the modem.  Eg Trumpet sends a mesage every 10 seconds even when no other activity is occurring.  In this case set the dialer to automatically disconect when inactive.

•	Closing the modem window does not cancel the WaitForModemIdle command.  Use the cancel button to do that.

•	Setting Max Seconds to 0 gives a maximum wait of 24 hours.


Class Name

Class Name refers to a windows class, as defined by the Windows RegisterClass function.  This is a description of the window type and remains constant for a given window in a given program.  Eg the main window for the Notepad applet has a class name of 'Notepad'.  This class name remains the same whenever Notepad is opened.

The class name for a window can be found by pressing the browse button ('...') in the Macro Editor.  This will open the Select Window Dialog.

Whenever possible use the class name when referring to a window rather than the title.


Key String

A key string is a list of keystrokes that will be sent to a open window.  In addition to the standard ascii keys, modifiers and special keys can also be sent.

Modifiers:

  ControlKey = '^'

  AltKey = '@'

  Shift key = '~'

Special Keys:

The following special keys may be sent by surrounding them with curly brackets {}

'F1' - 'F12'

'INSERT'

'DELETE'

'HOME'

'END'

'PGUP'

'PGDN'

'TAB'

'ENTER'

'BKSP'

'PRTSC'

'SHIFT'

'ESCAPE'

Eg a key string of '@FSmyfile.txt{ENTER}' will open the File Menu (Alt - F), select Save (S), give a filename of 'myfile.txt and save it {ENTER}.


Window Title
The Window Title is the Text that appears in the title bar of a window.  This can be used to locate a window.  However the window title may change while a program executes.  For this reason, using the Class Name is preferable.


Select Window Dialog

The select window dialog appears whenever the browse button is pressing while defining the following macro commands:

ActivateWindow

CloseWindow

SendKeysClass

SendKeysWindow

This lists all currently open windows.  Select the required window and press OK.  This will fill in the appropriate details in the Edit Macros window.


Tutorial 1: Notepad

The aim of this tutorial is to provide a brief look at some of scheduler's features.

•	Start Scheduler (No! Really?).

•	Press the 'Edit' button in the start screen to edit schedules.  This will bring up the Edit Schedules window.

•	Press the 'Add Item' button. This will insert a new scheduled item with a start time of 00:00.  You will now be able to edit the item using the Item Information boxes on the right hand side of the window.

•	Enter a Start Time and Days.  These changes will be reflected in the Scheduled items list box.  However as no macros have been defined, nothing will happen at that time.

•	Press the 'Macros' button.  This will bring up the Edit Macros window.

•	Press Add macro and enter 'Tut 1: Notepad' as the name for the new macro.

•	Press 'Add Item'.  This will add a new macro 'ActivateWindow Progman' to the macro list.

•	Click on the ComboBox displaying Activatewindow and select Execute from the drop down list.

•	Now, either type 'Notepad' in the edit box containing 'Progman' or click on the Browse ('...') button and select Notepad.exe using the file open dialog box.

•	Press the 'Test' button below the Command Info boxes.  This will run Notepad.

•	Now add a new item and change the command type to SendKeysClass.  Press the browse button and select 'Notepad     Untitled - Notepad' in the Select Window Dialog.  press OK.  This will enter 'Notepad' in the edit box.  Note, do not close or minimise notepad before doing this.

•	In the edit box labeled 'Argument 2:' enter the following: 'Welcome to my world.@FStut1.txt{ENTER}@FX'.

•	Press the Item Test button.  This will activate notepad, type 'Welcome to my world.' in Notepad, open the file menu, select save, enter a filename of tut1.txt, save it and then close notepad.  Using File Manager (or something) delete tut1.txt.  Now close the macro window using OK.

•	In the Macro Combo box select 'Tut1: Notepad'.  Close the Edit Schedule window using OK.

If Scheduler is running at the specified time then it will start notepad, enter a line of text and save it.


Tutorial 2: Agent

The aim of this tutorial is to produce scheduled items to start the Agent news reader program, retrieve subscribed newsgroups and then close Agent.

Start Scheduler.  Go to the Edit Schedules window and then to the Edit Macros window.  Add a macro called 'Run Agent'.

Start Winsock:

The first requirement is to start a winsock app.  Add an item.  Set the command to Execute.  Use the browse button to find the winsock application (eg Trumpet.exe).  Press the item Test button.  This should start up the winsock app.

Start Agent:

The second requirement is to start Agent.  Add another item and set it to Execute Agent.exe using the browse button to locate Agent (make sure the correct path for Agent is entered).  Test this.

Delay Execution:

Close both Agent and Trumpet (or whatever winsock app is being used).  Now test the macro using the Macro Test button.  This may cause a potential problem as Agent is being started before the winsock has finished loading.  The answer is to Delay executing Agent until the winsock has loaded.  Add a new item, Delay 45 and drag this to before Execute Agent.exe.  This will cause a 45 second delay before starting Agent.  Slower computers or modems may require a longer delay. Add another Delay 45 item after Execute Agent.exe.  This will provide time for Agent to load and initialise itself.

Do Something:

The next step is tell Agent to download subscribed newsgroups.  This is accomplished using SendKeys, SendKeysClass or SendKeysWindow to send simulated keystrokes to Agent.  However as the title of the main Agent window changes depending on the newsgroups selected, SendKeysWindow cannot be used.  Press the Macro Test button to start both winsock and Agent.  Now add a new command item.  Set the command type to SendKeysClass.  Use the Argument 1 browse button to open the Select Window Dialog.  Select the entry for Agent and press OK.  This will set Argument 1 to 'ForteAgent:Main', the classname for the main Agent window.

Downloading subscribed groups requires opening the Online menu (press Alt O) and selecting the 'Get New headers in Subscribed groups' entry (Press N).The keystrokes required to start downloading groups therefore are Alt O N.  This translates as a key string of '@ON'.  Enter this as Argument 2.  Pressing Test should activate Agent and start downloading groups.  Further SendKeys type commands can be used to carry out further Agent activity.

Quit and go home:

Add a Delay item.  This should be of sufficient length to allow Agent to carry out it's activities.  A value of between 600 (10 minutes) and 1800 (30 minutes) should be sufficient.

Add another item.  This time set the command to CloseWindow.  Use the browse button for argument 1 to set the class name to 'ForteAgent:Main'.  Test the item.  Sometimes Agent may still have tasks running.  In this case a messagebox will appear asking for confirmation.  Add Delay 10 and Sendkeys 'Y'.  This will give the messagebox time to appear and send 'Y' to force closure.

Finally add another delay of 30 seconds to give Agent time to quit and then add another CloseWindow, this time setting Argument 1 to the winsock window.  Test this item to close winsock.  Now test the macro (warning, this will take some time to run because of all the delays used).

Scheduling the Macro:

Close the Edit Macro window by pressing OK.  Now Add a scheduled item.  Set Time to 04:00, and Macro to 'Run Agent'.  Press OK to save the changes.  Leave scheduler running.  At 4 every morning, scheduler will automatically start winsock and Agent, download headers and close the programs.


Author Details

Scheduler is writen by Sean Cross.

Bug reports, hints, praise, criticism (if really necessary) to

Sean Cross

C/O 11 Albert St

Waipukurau

New Zealand

Sean@crm.co.nz


Known Bugs

SendKeysX:

Bug

Using SendKeysX twice in succession with long key strings can generate a GPF.

EG

SendKeysClass Notepad 'I do like to be beside the seaside'

SendKeysClass Notepad 'I do like to be beside the sea'

may generate a GPF on slower machines.  This is a bug in either SendKeys.dll or Windows, neither of which I wrote.  A one second delay has been incorporated in the SendKeys functions which should solve the problem except for very long strings on slow computers.

Workaround:

Where possible use a single SendKeys command.  Eg

SendKeysClass Notepad 'I do like to be beside the seaside'{ENTER}'I do like to be beside the sea'

up to a maximum of about 200 characters.  Otherwise separate the commands with a Delay.  Eg

SendKeysClass Notepad 'I do like to be beside the seaside'

Delay 1

SendKeysClass Notepad 'I do like to be beside the sea'

Helpfile

Bug

Registration error occurs if the help file path includes spaces.

WorkAround

Store the file in a directory path that does not contain spaces.

Helpfile

Bug

I' ve overwriten my dictionary somehow, so spelling errors abound.

WorkAround

Just be gratefull you don't have to read my writing.