Work Less
Put your feet up as Simon Williams shows you how to automate yout PC admin.
The PC was meant to make our lives easier, but as software gets more complicated and operating systems become richer in features, it's hard to remember who's serving who. More and more time seems to be lost in housekeeping just to keep your computer running smoothly.
This needn't be the case. With the deft use of a scheduler, various macro systems and the occasional batch file, just about any desktop or notebook can be made to handle its own backup, check its anti-virus security and provide a suite of keyboard shortcuts to make document creation a snip.
You don't need to invest in masses of new software to conjure these wonders. Much of what you need is already available, though not necessarily obvious, in Windows. Any utilities you may need to add are usually freeware or shareware and will cost you very little, while saving you a lot of time. Everything here can be done with a small amount of programming too, mostly by getting software to record your actions and repeat them automatically.
Creating Word macros
Many of the existing functions in Word are written in Visual Basic and there's no reason you shouldn't add your own. This doesn't mean learning VB – Word's macro facility will do just about everything you could need for day-to-day automation.
Before you start, work out the sequence of keystrokes that performs the function you want to add. When recording a macro, you can use the mouse to select options from menus and click on tools in the toolbars, but not to move the cursor or make selections in the document window. It's best to rely mainly on keystrokes.
When you've worked out the sequence you need, go to the Tools menu and select Macro/Record New Macro. This opens up the Record Macro dialog, where you enter the name for your new macro (which can't contain spaces, though capitals and underscores are okay). You're able to assign the new macro to a toolbar or menu, or you can give it a keyboard shortcut, which is probably the quickest way to use it. Click the Toolbars or Keyboard buttons and either drag the macro to a toolbar or assign it a keyboard shortcut.
Now start recording your macro. Type the sequence of keystrokes you worked out beforehand and, when you've finished, click the Stop Recording button in the Macro Recorder dialog that popped up when you started recording. This will return you to your document and, by default, save your new macro in the Normal template so it's available in all your documents. Try out your new macro by pressing the shortcut key you assigned it or by clicking on its name or icon in the menu or toolbar. If you want an example to play with, try entering SelectPara as the macro name, assigning it to <Alt-P> and recording F8 F8 F8 F8 Esc. This sets up a new macro that automatically selects the entire paragraph containing the cursor, which can be useful for deleting or moving a block of text. It's assigned to the key sequence <Alt-P> – four keystrokes quicker than pressing F8 F8 F8 F8 Esc each time.
Keyboard recorders
Macro recording in Word is all very well, but to automate the whole of Windows requires something a bit more general. Those who look back lovingly to Windows 3.1 may remember a Microsoft applet called Recorder: it recorded keystroke history, mouse movements and mouse clicks, and could play them back when called on to automate virtually any Windows operation.
Although Recorder hasn't been included in any recent version of Windows, there are plenty of programs that do pretty much the same thing. Run a search for 'keyboard recorder' at www.download.com or www.tucows.com and up to a dozen names pop up. Although they vary a lot in functionality, from the very simple to the terminally nerdy, there are a few that offer a good balance between ease of use and usefulness.
One well-designed and versatile example is Tasker, which costs around $32 after you've tried it for a month. This small shareware application pops up in a small window with one button to start recording, a second to stop it and a third to play it back. You can use both the keyboard and mouse in your recording, but as with Word you're better off using key sequences as much as possible, because mouse clicks rely on the position of the pointer on the screen. This may vary if, for example, an application window is a different size on playback than during the recording. Mouse clicks can have unpredictable results.
Once you've finished a recording, you may want to tweak it to get it just right, and it's possible to view the script file that Tasker generates and make small adjustments. There are only five basic commands in the program's repertoire, but using them with its recording facility can produce useful automation of just about any Windows application.
AI imitation routines
Recording and playing back short sequences of key presses and mouse clicks can be very useful for basic animation, but if you need more flexibility and the ability to put front ends and interfaces on your macros, you require a different type of application.
Imitate (www.imitation.uk.com) claims to use AI techniques to generalise from a specific set of actions it's given to copy. In other words, you show it how to pick information from one Website and you should be able to train the program to do the same thing for others. It does this through a system of 'learning tables' – a bit like worksheets – into which you enter the rules you want the program to assimilate.
As well as being able to learn by example, you can use the program to create complete applets, giving them buttons and checkboxes and enabling them to accept input when you run them. It's like a halfway house between keyboard recorders and a complete programming language, such as Visual Basic. It does all the hard work, without resorting to written scripts, and produces Java code at the end of it. It's not exactly cheap, costing around $165 for the full version, which makes it more suitable for those with serious applications in mind.
Batch files – still available
There has always been a system for automating repetitive tasks under Windows. Even under Windows XP, where DOS mode has been eliminated, you can still run programs written in Microsoft's batch language at the Command Prompt. Indeed, some parts of the batch language have actually been extended under Windows XP.
There are only eight commands within the batch file language: call, echo, for, goto, if, pause, rem and shift – not much scope, you'd think, for creating useful task animation. The clever part comes in using the batch commands with all the other commands you had in DOS, to copy files, create directory structures and run programs automatically.
It's fairly straightforward, for example, to write a batch file that copies the contents of important folders to external disks. This could form the basis of a simple but effective backup routine to help protect your files – something Windows XP Home sadly lacks. The batch language supports quite sophisticated structures, including parameters, so the batch files you create can take in different data each time they're run.
You could just as easily persuade the batch file processor to provide extra help for some of the more obscure commands the operating system understands. The main snag with using batch files to automate your PC is the lack of ready information on the batch file language. However, there