January 23, 2009

Screen Scraping with Macro Scheduler

Filed under: Automation,General,Scripting — Marcus Tettmar @ 11:50 am

What is Screen Scraping?

Screen Scraping is a term used to describe the process of a computer program or macro extracting data from the display output of another application.  Rather than parsing data from the database or data files belonging to an application, Screen Scraping pulls the data from the screen itself, extracting data that was intended to be displayed to the end-user as opposed to data designed for output to another application or database.  

Screen Scraping is necessary when there is a need to access the information displayed by the application but there is no method provided to access it behind the scenes.  The database or data files may not be accessible, or may be undocumented or proprietary and therefore cannot be parsed easily; the costs associated with interacting with the database may be too high; or the license agreement or warrenty prohibits it.  In the case of legacy systems that are no longer supported there may be no knowledge of the data structures, or the technology used is no longer compatible with current technology.  In these cases we are resorted to extracting the data from the screen – from the windows of the application.

The term Screen Scraping probably originates from the era of computer terminals when you could connect the terminal output of a computer to an input port on another and therefore record the screen data.  

Screen Scraping Methods

There are a number of ways we can retrieve information from the screen using Macro Scheduler, depending on the type of application the data is in.

Screen Scraping Web Applications

Applications like Macro Scheduler’s WebRecorder can access the data and objects inside an Interner Explorer window and can therefore be used to extract the data.  Technically speaking I would not call this screen scraping since WebRecorder is using an API interface provided by Internet Explorer, but the process of extracting information from web sites is commonly refered to as Screen Scraping.  With WebRecorder we can use the ExtractTag wizard to create code that extracts the text from a particular element in the page.   While WebRecorder is the easiest way to do it, it is also possible to automate IE and extract data from web pages by using VBScript. The following forum posts may help:

Automate Internet Explorer with OLE/ActiveX
Automate web forms with IE
HTTP GET and POST using VBscript

Screen Scraping Microsoft Office Applications

Microsoft Office Applications, like Internet Explorer, have a COM interface that allows scripts to manipulate them and access the data held within them.  Again, not really scraping data from the screen itself, as you are getting it directly from a programming interface.    There are a number of examples in the forums and blog archives and also some sample scripts that come with Macro Scheduler which demonstrate how to automate Office applications and retrieve data from them.  

Working with Excel

Screen Scraping Regular Windows Applications

Most other applications don’t offer a scripting interface like MS Office or Internet Explorer.  This is where we really need to work directly with the screen.   There are a number of ways we can do this kind of Screen Scraping with Macro Scheduler.

The Text Capture Functions

Macro Scheduler includes some Text Capture functions which can be used to extract text from a given window, rectangular screen area or screen point.  These functions use low level system hooks which monitor applications calling the various “TextOut” functions that Windows uses to output text to the screen.  By doing so they are able to capture this text.  The Text Capture functions return the text to  a variable which you can then use as needed.  

However, a few applications don’t use the Windows built-in functions to create and output text.  Don’t worry –Most do, but a few use their own techniques.  When you realise that text on the screen is just a sequence of small dots, if the application programmer decided to build his own routine to assemble text from dots rather than calling the Windows functions which already do that for you, you’re not going to be able to capture it.

The text capture functions and their limitations are explained here.  There is an example application, here, created with Macro Scheduler, which you can use to determine whether or not the text you want to capture can be captured using the text capture functions.

http://www.mjtnet.com/blog/2007/12/12/capturing-screen-text/
http://www.mjtnet.com/blog/2008/01/03/screen-scrape-text-capture-example/

Using the Clipboard for Screen Scraping

If the text you want to capture is selectable then you can use the clipboard to retrieve it.  A Macro Scheduler macro can send the keystrokes necessary to highlight and copy the text to the clipboard and then use the GetClipboard function to retrieve that text to a variable.  This is far less elegant than using the Text Capture functions but might be necessary if the application concerned is not utlising any of the Windows text out functions to create the text.

SetFocus>Notepad*
//Select ALL
Press CTRL
Send>a
Release CTRL
//Copy to clipboard
Press CTRL
Send>c
Release CTRL

//Get and display the data
WaitClipboard
GetClipboard>theData
MessageModal>theData

Screen Scraping via Optical Character Recognition

A final resort might be Optical Character Recognition (OCR). If the text is part of an image file neither the Text Capture or Clipboard methods are going to be able to extract it. But, depending on the quality of the image and the fonts used, OCR might. There are a number of OCR engines that can be used by Macro Scheduler, one of which is part of Microsoft Office. The following posts demonstrate how this can be done:

Screen OCR to Retrieve Otherwise Undetectable Text
Screen OCR – Recognising Graphical Text

More on Screen Scraping.

January 22, 2009

Quick Tip: Determine Path of an Application (Update)

Filed under: General — Marcus Tettmar @ 6:03 pm

When using the RunProgram command in Macro Scheduler to run an app you usually need to know the path (unless it’s a system app already in the path) and executable name. Sometimes it’s not obvious what that is. You might start Microsoft Word, or Internet Explorer several times a day without knowing or caring what its exe name and path is. So when you come to write a macro which calls it how do you find out what it is? Well you might think to right click on the application’s shortcut and look at the properties. But this doesn’t always help. If I click on the MS Access shortcut in my Start menu it seems to point to yet another shortcut. I could locate that shortcut and look at that I suppose, but I’m an impatient kind of guy and don’t like being sent around the houses. No, there’s a quicker way:

  • Start the application if it is not already running.
  • Hit Win-R to get the Run dialog and type msconfig32 and hit Enter
  • In the System Information window expand “Software Environment” and click on “Running Tasks”
  • You will see a list of running processes with their Path shown in the second column

Running Task Location

In Vista you can also do the following:

  • Start the application if it is not already running.
  • Start Task Manager (which you can do quickly by right clicking on the task bar and selecting “Task Manager”).
  • Look down the list (you can sort it by name or description) to find the application.
  • Now you can right click on the application’s entry and select Properties and it will show you it’s location. Or right click and select “Open File Location” to see it in an Explorer window.

The location field in the Properties box of Task Manager can be selected, so you can just copy this to Macro Scheduler.

So, even if you don’t know where an application is installed or what its executable name is, it’s easy to find that out once it’s running.

__

Updated 23/01/09 for an XP solution. Thanks to Dick Lockey for pointing out my Task Manager solution was Vista only.

January 20, 2009

MJT Net T-Shirts and Merchandise

Filed under: Announcements,General — Marcus Tettmar @ 5:03 pm

Thanks to Zazzle we can now offer MJT Net Logo T-Shirts and merchandise.

MJT Logo T-Shirts and Merchandise

Just what every Macro Scheduler user always wanted! View the products at the Zazzle store here. Oh, and by the way – Zazzle are currently offering an “Inauguration Weekend Sale!” which ends today. So act quickly if you want a good deal.

January 14, 2009

New Linux User Misses Macro Scheduler

Filed under: General — Marcus Tettmar @ 5:57 pm

A while back I got this comment in an email:

“I loved Macro Scheduler. Unfortunately, I’m now working exclusively on Mac and Linux boxes. I have kept a copy of Macro Scheduler, just in case I ever return to Windows, and have recommended it to many friends (2 of which have purchased copies).  After 2 years without Windows, I have to say that I don’t miss Windows, but I do miss Macro Scheduler.”

Despite the fact that we’ve lost a customer to Linux, I think that’s quite an endorsement. Linux has always catered to the sysadmin with its rich command line interface, and all Linux tools, utilities and system apps provide a command line processor. Linux also comes with a number of built-in scripting languages and an advanced scheduler called Cron. So Linux is made for being automated. Windows, on the other hand, was designed almost exclusively for human users and is purely graphical. Therefore, tools like Macro Scheduler are required to automate Windows applications. Nice to hear how important Macro Scheduler was to this sysadmin when he had to put up with Windows 🙂

January 9, 2009

Unicode – Does anyone read release notes?

Filed under: General — Tags: — Marcus Tettmar @ 2:19 pm

Probably the biggest change in Macro Scheduler 11, though not visual, was Unicode support. For Macro Scheduler to support Unicode in scripts it has to save the script files with Unicode encoding rather than ANSI encoding. And if you open a Unicode file up in an ANSI editor it’s going to look garbled. Since older versions of Macro Scheduler were ANSI only and didn’t know anything about Unicode, if you open a v11 script up in v10 (or earlier) that script is going to look wrong.

The v11 release notes have a big warning about this. Nothing is damaged permanently and it doesn’t have any effect on upgrading. It’s only an issue if you edit or create a script in v11 and then, for whatever reason, try to open it in an earlier version. So if, for example, you’re running v11 and you have another PC running v10 and you create a script on your PC and wish to open it on the PC running v10 it’s going to look messed up.

One solution of course is to upgrade that copy of v10 to v11.  But there is another solution. You can tell v11 to save the script with ANSI encoding. From the editor use File/Save As and then in the file type box select “ANSI Script Files”. Alternatively just open the script file up in Notepad and save it again, selecting ANSI in the Encoding box. This of course assumes that you don’t actually NEED Unicode. If you have Unicode characters in your script which you need to use, then clearly saving as ANSI will destroy them. In which case you do need to upgrade that v10 installation to v11.

Macro Scheduler Runs In Windows 7

Filed under: Announcements,General,Macro Recorder,Windows 7 — Tags: — Marcus Tettmar @ 2:05 pm

Whenever Microsoft release a new operating system I’m always a little anxious to make sure we test Macro Scheduler on it as soon as possible and find out what, if anything, needs to be changed. I’ve been following news about Windows 7 for a while now and, reading that it was built on the same core as Vista and Windows 2008, I fully expected Macro Scheduler to run fine on it. But there’s nothing like seeing it in the flesh to be absolutely sure. So when Windows 7 Beta was made available to MSDN subscribers yesterday I didn’t waste much time in downloading it.

Installing Windows 7 into Virtual PC was nice and easy and I’m pleased to say my expectations were right – Macro Scheduler 11 runs absolutely fine.  Everything works as expected, including the macro recorder and even low level stuff like text capturing.  Here’s a screen shot of Macro Scheduler 11 running in my virtual Windows 7 environment:

Macro Scheduler in Windows 7

Macro Scheduler in Windows 7

January 6, 2009

New Year, New Site, New Look, New Logo, New Podcasts

Filed under: Announcements,General,Podcasts — Marcus Tettmar @ 4:29 pm

Happy New Year everyone!

And it’s not just a new year.  Everything else is new too.  Not content with a new release (Macro Scheduler V11) which we got out early in December we felt it was high time for a new look as well.  So along with a nifty new logo we have a new site design, as you will see if you are reading this on the web site.  If not, head on over to www.mjtnet.com and check it out.

There’s one very minor glitch noticeable only if you are using IE6, which is probably the worst web browser ever made.  Unfortunately, amazingly, according to our web server logs 35% of hits come from IE6.  If you are one of those using IE6 ditch it now!  Upgrade to IE7, or, better, try Firefox or Google Chrome if you have to.  Please.  Ok, we’re working on the IE6 issue.  Rant over.

If you spot any broken links, please let me know.

Also new is a series of Macro Scheduler user podcasts.  We thought it would be cool to interview some Macro Scheduler users, find out more about them and how they are benefiting from the software, what kinds of things they’re doing with it.  We figured rather than doing stuffy old case studies it would be more fun to be a bit more informal and create some podcasts.  You’ll find them over on the Customer Testimonial page.   So far there are six podcasts.  You can hear how Mitch Vincent uses Macro Scheduler for automated data input and software testing at K-Software.  Paul Griffin speaks about AppNavigator, how it is helping make mortgage approvals more efficient and how he became an MJT Net partner.  Antonius Momac also talks about software testing at Triple Point Technologies. Phil Lewis from Siemens tells us how Macro Scheduler helps him administer a large DNS network.  Bob Hansen talks about how he’s made a living automating his clients’ processes; and Keith Passaur of eDocFile talks about document imaging automation.

“I couldn’t work without Macro Scheduler. It is the glue that allows me to automate all the other office applications together.  I couldn’t support my customer’s without it.  I’m just so happy I found it when I did.”  Bob Hansen.

It’s great to hear how different people are using and benefiting from Macro Scheduler, and it’s really useful for other people working in similar areas.  Hopefully this will become a regular series.  If you would like to take part, drop me a line and we’ll set it up.  If you would like to get in touch with anyone featured in a podcast you’ll find links to their company websites on the podcast page, most of them hang out in the forums, or you can just drop me a line and I’ll put you in touch.

You can also subscribe to the podcasts at iTunes.  Here.  Enjoy.

All the very best for 2009 folks!

December 15, 2008

Mass Import of Scripts and Groups to v11

Filed under: General — Marcus Tettmar @ 11:23 am

Because Macro Scheduler 11 saves scripts with Unicode encoding, and previous versions understand only ANSI encoding the decision was made to install Macro Scheduler 11 into its own folder, with its own data folder and registry hive. By keeping it entirely separate from previous versions it can run side by side with a previous version without any chance of scripts being prevented from being opened in the old version. If you open a script up in v11, save it, and then try to open it in v10 it will appear corrupt (though this is recoverable – more in a sec). So for those that will continue to use v10 for a while it is sensible to keep things separate.

However, if you are happy and ready just to point v11 at your existing setup you can do so quickly by exiting Macro Scheduler and modifying the following registry entry:

HKCU\Software\MJTNET\MSched11 – DataDir

Replace the value of DataDir with the path to your existing Macro Scheduler macro folder.

You’ll also want to copy comdef.ini from the Samples folder in the Macro Scheduler 11 Program Files folder into the macro folder above, overwriting the previous one – this contains the function definitions for the code builder – so you’ll want the v11 one.

Alternatively, if you still want to run v10 but want a complete copy, copy the entire contents of your v10 macro folder to the v11 macro folder (apart from comdef.ini). Then open up groups.ini and do a search/replace on the root macro folder so that all groups are now pointing at the new v11 folder.

In either case, make sure you exit Macro Scheduler fully first.

If you ever need to open a script in v10 (or earlier) that was edited/saved/created with v11 then do one of the following:

1. Open it in v11 and select File/Save As and select “ANSI Script Files” in the “Save as type” box, or,
2. Open it in Notepad, do File/Save As and select “ANSI” in the Encoding drop down.

December 9, 2008

Direct Access 2.0 – Text Shortcuts

Filed under: Announcements,General — Marcus Tettmar @ 9:07 pm

Direct Access - Text Replacement MacrosVersion 2.0 of Direct Access, a great text replacement, text shortcut tool, was released by our friends at Nagarsoft today.

Direct Access lets you assign actions and autoreplacements to text abbreviations. I use it to launch frequently used applications. E.g. I’ve assigned the text “ftp” to Filezila, my FTP client. So now, wherever I am in Windows, whatever application I’m in I can just type “ftp” and hit F12 and Filezilla is launched.

You can also use it for text replacements and text insertions. E.g. type “sig” when you need to insert your signature into an email or usenet or forum post. And of course you can also have Direct Access run Macro Scheduler macros. So you can make text shortcuts that run Macro Scheduler macros whatever application you are working in.

Version 2.0 has a redesigned interface to enhance ease of use; support for inserting rich text; network support for sharing action groups between PCs; confirming commands with delimiter keys such as SPACE and ENTER; and more.

Because Direct Access compliments Macro Scheduler so well we’ve arranged a special discount for Macro Scheduler customers. Macro Scheduler users can get 25% off the regular price of Direct Access. Registered users will find a discount coupon in the secure download area.

Congratulations to Nagarsoft on a great update to an already superb tool. Check it out.

December 5, 2008

Automated Software Testing Success

Filed under: General,Testing — Marcus Tettmar @ 5:20 pm

A couple of great posts in the new Software Testing forum are demonstrating the power of Macro Scheduler for automated testing.

Antonius Momac says in this post:

I’ve looked at more than 8 other automation tools. Some were from the big companies with many products like IBM (rational), HP/Mercury, and other more focused shops like Automated QA, Tethy Solutions, Redstone (eggplant) ….. However, the application I was putting under test was very particular. In fact, plain and simple, Macro Scheduler was the only tool that worked.

In this post Gale Dyvig said:

We found the problem with object orientated test tools like WinRunner, QTP, SilkTest, etc is the partial or nonexistant support for the objects under test. As new technologies are created the problem gets worse.

These tools have image based workarounds, but they need the script to specify the image location on the screen. We tried some workarounds based on a WINAPI command similar to GetPixelColor to find the images. It worked but was nowhere as well developed or convenient to use as Macro Scheduler’s FindImagePos. If you have bmp’s the images your application will display, you can write a script before the application is coded.

Macro Scheduler and AppNav are great because the same solution works for all technologies runnable on Windows. Because the solution is image based it works in development, independent test, and production environments.

Are you using Macro Scheduler for automated software testing? If so please post an introduction in the Software Testing forum. I’d love to know more about how people are using Macro Scheduler in automated software testing scenarios.

« Newer PostsOlder Posts »