Error Code Utility
I posted a link to a list of system error codes before. But I recently found this handy little utility which gives you a quick way to look up a Windows error code and find out what it means. Good to have on your desktop.
Macro Recording and Automating Windows with Macro Scheduler – Tips & News
I posted a link to a list of system error codes before. But I recently found this handy little utility which gives you a quick way to look up a Windows error code and find out what it means. Good to have on your desktop.
Most of the time when we are automating a process we are able to predict the sequence of events. We are working with a deterministic process and a linear flow of actions. But there are occasions when things can happen during a process that we cannot predict precisely. E.g.:
There are a number of ways we can deal with such situations.
Window Event Schedules
If you have a situation where a known window can randomly appear – say a known error box – which always has the same window title, the simplest approach is to use the Window Event schedule in the Advanced Scheduling properties. Simply create a macro which closes the box – perhaps all it has to do is press enter – and specify the window title under Advanced Options in the macro properties. Then whenever Macro Scheduler sees this window it will run the macro and clear it.
Synchronous Coding
In the case where a window may, or may not appear after entering some data into a field, say a data validation dialog, we could just deal with this after sending the text, in regular fashion – something like:
Send>the_data Wait>0.5 IfWindowOpen>Verification Alert Press Enter Endif
So we simply send the data then IF the verification window appears, close it. But what if you have hundreds of data fields to enter? Dealing with each one would involve a lot of extra code.
OnEvent Window Event Handlers
Another way is to use the OnEvent function to create an event handler in your main script. There are three types of window events that can be monitored with OnEvent:
OnEvent is used to create an “event handler” which is just a subroutine which will be executed whenever the event occurs. So, for example, using OnEvent you can tell the script to run a subroutine whenever a specified window appears, whenever that may be, while the rest of the script is executing.
So let’s say we are working with an application which could, at any time, pop up a warning box titled “Connection Error”, and this can be cleared just by pressing enter to hit the default OK button:
OnEvent>WINDOW_OPEN,Connection Error,2,CloseWarning .. .. rest of script here .. SRT>CloseWarning Press Enter End>CloseWarning
Of course there are a whole load of other things you can do. We may have a window whose title is always the same but the content differs and we need to react according to the content. In this case our event handler subroutine would have extra code in it to determine which type of dialog it is. We might do this using the text capture functions to read the text from the dialog, or using Screen Image Recognition to check for the presence of an object.
Maintaining Focus
Here’s an idea for an event handler which ensures the target application is always focused. If another application should steal focus at any point during the running of the script, it just grabs focus back again. It’s always good advice to use SetFocus before sending text. But if you have thousands of Send commands and want to slim down your script and make it more readable you could use this approach. Anyway, it’s just an example:
.. your code here to start and focus the app you want to automate, e.g.:
Run>Notepad.exe
WaitWindowOpen>Untitled - Notepad
//assuming the target window is now focused, get it's handle and process name
Let>WIN_USEHANDLE=1
GetActiveWindow>MyWindowHandle,x,y
GetWindowProcess>MyWindowHandle,pid,MyProcessName
Let>WIN_USEHANDLE=0
//now set up the event that is fired when a new window appears
OnEvent>WINDOW_NEWACTIVE,0,0,HandleNewWindow
..
..
.. rest of script here
..
..
//When a new window that does not belong to our process appears,
// set focus back to our window
SRT>HandleNewWindow
Let>WIN_USEHANDLE=1
GetActiveWindow>hwnd,x,y
GetWindowProcess>hwnd,pid,winProcName
If>winProcName<>MyProcessName
SetFocus>MyWindowHandle
Endif
Let>WIN_USEHANDLE=0
End>HandleNewWindow
Note how this code gets the window handle and process name of your target window. Then whenever a new window appears the HandleNewWindow subroutine is fired which gets the process name of the active window. If the process name of the new active window is not the process name of your target window (i.e. the new window belongs to some other application) it sets focus back to your original window.
I hope this gives you a useful introduction to OnEvent event handlers and how they can be used to run code at any point during the script in response to events. OnEvent can also be used to detect files, dialog events, dialog changes and keyboard and mouse actions. For further information please see OnEvent in the help file.
PDF documents are everywhere, but most of us don’t have the means to edit them. I’ve often received forms or agreements in PDF format and have had to print them off to complete and sign them only to scan them again to send in an email. But there’s an end to this madness in the form of a neat and inexpensive piece of software called PDF Annotator from our friends at Grahl Software. PDF Annotator lets anyone edit directly on top of a PDF file – add notes, comments, corrections, drawings etc. Ideal for filling in forms, adding your notes to technical manuals, or correcting other people’s work.
PDF Annotator will be on Software Deal of the Day on Wednesday 5th March.
I just love this quote:
βThe IT division of First State Bank of Altus was on a theoretical 25th floor and everyone was taking the stairs. The implementation of Macro Scheduler Pro from MJT Net provided us with a much-needed elevator.β
– Garry Petzold, Chief IT Officer, First State Bank of Altus
Taken from our latest case study with First State Bank of Altus, which shows how automation with Macro Scheduler Pro has saved them up to $2000/month on ATM over-withdrawels and over $50,000 per year on staffing costs.
My favourite text shortcut tool, Direct Access, is on special at Software Deal of the Day today, with 50% off.
If you’re in the UK watch out for next month’s issue of PC Plus magazine (issue number 266). A full, unrestricted, licensed, copy of Macro Scheduler 8.0 will be on the cover disc. And inside you’ll find a discount code for version 10 – the latest and greatest.
There’s a new Software Deal of the Day site about town. It is called, appropriately enough, Software Deal of the Day and it can be found at www.software-dod.com.
Each day the site features a different software title with a juicy big one-day-only discount. Unlike other similar sites they also offer a “Second Chance Discount” after the software has been featured.
Macro Scheduler will be offered on Software Deal of the Day on February 4th. So if you haven’t got a copy of Macro Scheduler yet, keep your eyes peeled for the one-day discount.
We made the front page of Modern Applications News print edition, with the headline “Software Saves $320 Per Day”. Here’s the article in their online edition: Software Makes the Front Office as Efficient as the Shop Floor
James Isaac Tettmar was born Friday 18th January at 0938 GMT. Mother and baby both well. A great start to the year! π
The editorial comment in the latest issue of Computing magazine discusses how IT may hold the key to preventing a recession:
“Financial institutions are looking for IT-enabled efficiency to help them through a sticky patch”
Regular Macro Scheduler users don’t need to be told how much automation can boost productivity and increase efficiency. Just look at how Iowa Laser have made efficiency savings of $75,000 every year since introducing Macro Scheduler to help streamline many important business processes.
In difficult economic times firms need to cut costs, become more efficient and more productive. By automating more of their business processes they can improve reliability and free up important resource to concentrate on their bottom line and become more competitive.