Macro Scheduler 15

Building The Script


 

Let's make a list of what our script needs to do:

 

Run Notepad

Wait for Notepad to be ready for input

Send the lines of text

Save the document

Print the document

Close Notepad

 

Steps 4 and 5 will probably need to be further broken down ? they will involve some key sequences and dialogs.  Let's run through the process manually.

 

This is what Notepad looks like when we run it.  The first thing to note is the Window title:

 

"Untitled ? Notepad"

 

Notice that focus is already in the editor portion (i.e. the editor is already active), so to send our lines of text we can just go ahead and start typing.

 

 

So I've written some text and now I want to save the document.  Let's see what the key sequence is for this.

 

ALT-F opens the File menu.

ALT-A will perform the Save As.. action.

 

Therefore ALT-FA will do this in one go.

 

Remember:  ALT-FA

 

 

The ALT keystrokes that issue a command are underlined on Windows.  So, when Notepad is opened, the first item is marked File ? this tells us that if we press 'ALT' and 'F', the File menu will appear.

 

 

So, back to our example.  When we press ALT-FA we get the "Save As" dialog box.  Note that the window title is "Save As" and the focus is already in the filename box ? this will be helpful.

 

So when we do this manually, we are subconsciously waiting for the Save As dialog box to appear and then we can type the filename.  Normally most of us would probably use our mouse to locate the folder we want to save the document in and then provide a filename.  However, we can, of course, type the full path and filename directly into the filename box and just press Enter.  Assuming we were able to get this right first time it would work.  Well, of course, our script will manage this happily because we're going to define the filename up front.

 

Notice that the Save button on the Save As dialog is the default object ? this means that just Pressing Enter will save the file.

 

So we have determined the actions required for the first part of our process:

 

- Run Notepad

- Wait for the window "Untitled ? Notepad"

- Send our lines of text

- Press ALT-FA

- Wait for the window "Save As"

- Send our filename

- Press Enter

 

So let's turn this into a Macro Scheduler script.  Read through the following sections in turn.

 

Run Notepad

Wait for the window "Untitled ? Notepad"

Send our lines of text

Press ALT-FA

Wait for the window "Save As"

Send our filename

The Script So Far

Printing the Document

Closing Notepad