Test nicely and share …
Really nice article over at StickyMinds by Lee Copeland: All I Ever Need to Know about Testing I Learned in Kindergarten.
Macro Recording and Automating Windows with Macro Scheduler – Tips & News
Really nice article over at StickyMinds by Lee Copeland: All I Ever Need to Know about Testing I Learned in Kindergarten.
I spoke too soon re WebRecorder and IE7. Microsoft have improved the way SELECT fields (drop down boxes) work in IE7. For previous versions of IE, WebRecorder has to use a convoluted process to detect clicks on SELECT fields and find the corresponding drop down object (Internet Explorer_TridentCmboBx). In IE7 things are much simpler and they are exposed just like other HTML elements. So we’ve updated WebRecorder today to handle this. WebRecorder 1.65 now works with IE6 and IE7.
Registered users can download the update from the registered downloads area. Evaluation downloads are here.
What would you like to see in the next version of Macro Scheduler? As always, we’d like your input. You can post suggestions for new features and functions in the Enhancement Suggestions forum.
I’ve added two new scripts to the Scripts & Tips forum.
How to run a process and kill and restart it if it is taking too long:
http://www.mjtnet.com/usergroup/viewtopic.php?t=2574
How to write to the Application Event Log:
http://www.mjtnet.com/usergroup/viewtopic.php?t=2577
Internet Explorer 7 Beta 2 went public today. Finally IE has tabs! Download it here. ZDNet have a review here. This beta version is likely to have bugs and may not display some sites properly. Microsoft want site designers to test it out fully before it is shipped later this year with Vista. I’ve tested WebRecorder with IE7 and am pleased to note that there are no issues and web activity is recorded and played back correctly.
Recently I wrote about why it’s good to automate and how automation can help you learn software and improve its design. There are other good reasons for automating beyond the obvious benefits of saving time and money.
Documentation: Automation scripts are the ultimate way to document a process. A script that automates a process describes how to carry it out properly. Businesses need to document all their manual processes so that other people can carry out the task. By scripting the process it is being described at the same time. As well as saving time by automating it, it is also now easy for someone else to see how the process is carried out.
Contingency: Contingency goes hand in hand with documentation. If only one person in the organisation knows how to carry out a task there will be problems if and when that person is sick, on vacation, or leaves the company. Not all absences are planned. By documenting a process the business is ensuring that someone else can carry it out should the usual task owner be unavailable. Automation takes that one stage further. If the process is scripted and automated it is easy for someone else to take on ownership of the task in the future. The task will continue to run and the script itself describes how the task works.
We released the first 8.x maintenance release today. This fixes a few small bugs. You will find full details here:
http://www.mjtnet.com/usergroup/viewtopic.php?t=2568
Nothing much to do with Macro Scheduler this except that it finds me sitting in an office in Geneva today. 100 meters beneath me, under the ground, is a circular tunnel 35m wide, 55m tall and 27 km long. It goes right underneath houses and offices in the city of Geneva and surrounding areas. Sandwiched between Lake Geneva and the mountains is the largest particle accelerator in the world, run by CERN, where Tim Berners Lee invented the World Wide Web. Next year they will accelerate protons around this tunnel and smash them together to create conditions similar to those that existed just after the Big Bang. They’re looking to prove the existence of a particle called the Higgs Boson, which is believed to provide matter its mass.
If you think you’ve created long scripts in Macro Scheduler you should see the software they’re creating at CERN to configure and measure the results from the particle accelerator. A friend of mine is debugging this C++ code right now and he says it takes 30-40 minutes to compile! That’s a lot of code. Think about that next time you’re debugging a script! 🙂
I was interviewed yesterday for Channel9’s New MicroISV Show. It will be aired in 5-6 weeks.
MicroISV is a new term to describe small software companies like MJT Net Ltd. ISV stands for Independent Software Vendor. The show is aimed at developers and small software companies and will give an insight into the benefits and challenges faced by small companies developing for the Windows platform.
This is something that comes up often, so I thought I’d mention it here. Every so often we get asked how to put a date into a filename. Say you want to rename or save a file with the date in the filename formatted to reportsYYYYMMDD.txt e.g.:
reports20061801.txt
Well the simplest way to do this is to use the basic date functions Year, Month and Day. These each return the current year, month and day numbers. We also need to embed the variables into the filename. We can create the filename like this:
Year>the_year
Month>the_month
Day>the_day
Let>filename=reports%the_year%%the_month%%the_day%.txt
See how we embed the variables by putting % symbols around them. The % symbols tell Macro Scheduler to find the variable within them and to use the value assigned to that variable. So on 18th January 2006 we get:
the_year=2006
the_month=01
the_day=18
And filename becomes:
filename=reports20060118.txt
Say we wanted to rename the reports.txt file to a reports20060118.txt. Let’s also say that the file is in the c:\data folder. We would do this:
MoveFile>c:\data\reports.txt,c:\data\%filename%
Or we could have said:
Let>filename=c:\data\reports%the_year%%the_month%%the_day%.txt
MoveFile>c:\data\reports.txt,filename
You might not be renaming a file, but sending the filename to an application. Most applications use the standard ‘Save As’ dialog. Once this has opened you can send the full path and filename directly to that box and hit the Enter key to perform the save. So after sending the keystrokes required to open the Save As dialog (often File/Save As) we’d do:
WaitWindowOpen>Save As
Send>c:\data\reports%the_year%%the_month%%the_day%.txt
Press Enter
The Year command returns the year in full 4 digit form. Suppose you only wanted the last two digits (06 in this case). Well we can use the MidStr command to extract the last two digits:
Year>the_year
MidStr>the_year,3,2,the_year
This says: Starting from the third character in the_year take two characters and return the result in the_year. In this case because the_year has previously been declared as a variable (by the Year command) it is seen as a variable. The result of the MidStr command is also the_year so it over writes the_year with the new value. We could have made a new variables:
MidStr>the_year,3,2,YY
Here we end up with a new variable, YY, which contains 06.
To understand this better, paste the following code into the Script Editor. Then open the Watch List (Debug/Show Watch List). Now place the cursor on the first line and hit F8. Each time you hit F8 the script will advance to the next line. You will see the new variables being created in the watch list to the right. And you will see their values changing as you advance through the script.
Year>the_year
Month>the_month
Day>the_day
Let>filename=reports%the_year%%the_month%%the_day%.txtMidStr>the_year,3,2,YY
Let>newfile=outcome%YY%.dat
You might want to use a previous or future date. For more advanced date manipulation I recommend using the VBScript date functions.
Let’s say we want to use yesterday’s date in the filename, instead of today’s. To determine past or future dates based on today’s date use the VBScript function DateAdd. DateAdd takes an interval type, a number and a date. To add one day to the current date do:
DateAdd(“d”,1,Date)
To subtract one day from the current date we use:
DateAdd(“d”,-1,Date)
So to create a dated filename based on yesterday’s date we can do this:
VBSTART
VBEND
VBEval>DateAdd(“d”,-1,Date),yesterday
VBEval>Year(“%yesterday%”),yyyy
VBEval>Month(“%yesterday%”),mm
VBEval>Day(“%yesterday%”),dd
Let>filename=reports%yyyy%%mm%%dd%.txt
Here we use VBScript’s version of the Year, Month and Day functions which operate on a given date. First we subtract one from the current date to get yesterday’s date and we use that in the Year, Month and Day functions to extract the relevant parts and then we can construct our filename.
See the VBScript Documentation for more info on using VBScript functions.