December 3, 2010

Macro Scheduler 12.1.2 Update – AutoLogon Installer Fix

Filed under: Announcements — Marcus Tettmar @ 11:31 am

Macro Scheduler 12.1.2 is now available for download from the usual locations (registered updates | trial versions).

This is actually just a change to the AutoLogon component installer and not to the core product. We found a small error in the way the AutoLogon component was being configured in the registry which was preventing it from working properly on some customer systems.

So if you were having problems getting AutoLogon to work please download this update. If you do not use AutoLogon you do not need to update.

December 2, 2010

Video Tutorial – Macro Scheduler for Non-Technical Beginners – Part 2

Filed under: Announcements, Automation, Tutorials — Marcus Tettmar @ 9:59 am

Another contribution from Peter Begelsdorf which takes off from where his last video left off. Aimed at complete beginners this video demonstrates how to execute a file and wait for it to be ready before sending text and keystrokes to it.

Part 1 of this sequence and other videos can be found on the Video Tutorials Page.

This video is a result of my recent offer for free licenses and updates in exchange for video tutorial contributions. If you want to have a go at creating a tutorial please let me know.

November 30, 2010

Video Tutorial – Macro Scheduler for Non-Technical Beginners – Part 1

Filed under: Announcements, General, Tutorials — Marcus Tettmar @ 10:57 am

Following my recent request for video tutorial contributions long-time Macro Scheduler user Peter Begelsdorf has stepped up to the plate and put together a short tutorial aimed at the non-technical beginner.

This slick three minute video introduces the fundamental, yet very important, SendText and Press commands and shows beginners how to create a simple text macro assigned to a hot key.

Peter is now planning to create a sequel to expand on the basics and explain how to execute a file and wait for a program to be ready.

While many of my regular readers may be amongst the more technical and experienced Macro Scheduler users I think these new videos will be a great help to newcomers to the software.

Peter Bengelsdorf is a media integration consultant who was a newspaper editor when he started using Macro Scheduler more than a decade ago. For his contribution Peter has been awarded free future Macro Scheduler updates and a WebRecorder license.

If you would like to create a video tutorial or have ideas for one, please let me know. We’re giving away licenses and future upates to video contributors.

This tutorial has been added to the Video Tutorials page.

November 23, 2010

Support Email Rant

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

I received the following email today (I have paraphrased and anonymised it to protect the innocent):

“We were given a Macro Scheduler script to run on our system that someone else wrote which we are trying to use with your trial version. It doesn’t work. Your product seems to be very flaky and unreliable. Is this a feature of the trial version?”.

Now, when I read an email like that I have to breathe carefully and compose myself. To see what’s wrong with it let’s reword the same message as if it were talking about a different product:

“We were given a VBScript file which someone else wrote and we are trying to run it on our system but having problems. Microsoft VBScript must be very buggy!”

Yeh, so because a script that someone else built using a particular product is buggy the user thinks it is the product that is buggy. It seems not to have occurred to them that the script they were given is clearly not put together very well, or at least not written to run on their system. It hasn’t crossed their mind to report back to the person who wrote the script. For all we know the person who wrote it never intended it to be run on any other system but his/hers anyway.

You can build all kinds of dodgy, bug-ridden and dangerous software with C++. Does that mean Microsoft Visual Studio has a bug?

I’ve downloaded lots of dodgy VBscript code snippets, buggy PHP files and Perl scripts that fail to do what the author says they do, or need tweaking to work on my system. It never occurred to me to blame the VBScript, PHP or Perl interpreters. Next time rather than email the author of the code I’ll email Microsoft, PHP.com or Larry Wall instead.

Sheesh.

November 18, 2010

WebRecorder Update

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

WebRecorder and the IEAuto runtime have been updated as follows:

IEAuto 2.08 :

  • Added the ability to specify classname for ClickTag
  • Fixed issue where some fields may not click in IE8/9

WebRecorder 2.4:

  • Added Name/ID to Tag Extraction Wizard and will now output an ExtractTagByName if an ID or Name is present
  • Workaround for pre-focused fields to ask user to mouse click in element to identify it
  • Added detection of classname for ClickTag
  • Fix for situation where a form has no name (was previously returning [Object])
  • Removed old tag extraction drop down from toolbar and added Tag Extraction Wizard button

Registered Updates | Trial Downloads

November 17, 2010

Video Tutorials Needed – Make A Video!

Filed under: Announcements — Marcus Tettmar @ 11:01 am

We need to add more video tutorials. There are thousands of forum posts, blog posts and articles on this site but so far we’re shamefully low on video tutorials.

So I need your ideas. I’m not very good at coming up with contrived examples and I’m also the kind of person who learns by doing, so perhaps that’s why I struggle to come up with training guides and videos.

So, you can do one of two things:

1) Send me your ideas for a video. Don’t be too vague. Videos need to be short, so it needs to be fairly specific. Saying “Do a video on dialogs” is not that helpful. Which bit of dialogs? But remember that not everyone has the same applications, so any example needs to be reasonably generic. I can’t do a video on “automating SAP” for example. That’s actually TOO specific.

OR

2) Create a video yourself! All you need is the free version of Jing and a microphone. Assuming we think your video is appropriate we’ll put it on our site on the video tutorials page with your bio and web link if you have one (so you can promote your services if appropriate). We’ll also reward all contributions with free licenses/updates. You could even make a name for yourself!

Email me your ideas or contributions here.

November 15, 2010

Creating Native Function Aliases for Win32 Functions

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

The other day I posted a response on the forums which uses LibFunc to run the Win32 API function GetKeyState. This prompted someone to email me the following:

I didn’t know the Win API call to check for a key being down. The API call works but have you considered adding a native MS command called KeyDown> or maybe CheckKeyDown>

Well, it’s already possible to create native looking functions for DLL functions and therefore Win32 API functions.

We can do this by creating an Imports file in the Imports sub folder of Macro Scheduler. Let’s make an import file for some functions in User32.dll:

Step 1. If you don’t already have an Imports subfolder inside the Macro Scheduler program folder, create one: c:\program files\Macro Scheduler12\Imports

Step 2. Create a symbolic link to the appropriate DLL in this folder. Start a CMD prompt and CD to the Imports folder and for User32.dll type the following:

mklink user32.dll c:\windows\system32\user32.dll

If on a 64 bit system replace system32 with syswow64

This will create a link to the DLL in the Imports folder. Next we need to make a corresponding INI file.

Step 3. Create a file called User32.ini in the Imports folder. Inside this file create entries for each function you wish to import. E.g.:

[GetKeyState]
FunctionName=GetKeyState
Parms=1
Parm1=INT

[SendMessage]
Parms=4
Parm1=INT
Parm2=INT
Parm3=INT
Parm4=INT

[FindWindow]
Parms=2
Parm1=PCHAR
Parm2=PCHAR

Now, instead of writing:

Let>VK_UP=38
LibFunc>user32,GetKeyState,result,VK_UP

You can write:

Let>VK_UP=38
GetKeyState>VK_UP,result

So here’s a project for someone or a group of people: Create a User32.ini file for a fuller list of compatible functions which we can share on the website. Any function that accepts either integers (INT) or strings (PCHAR) and returns an integer (or nothing) can be included. And then we want another one for Kernel32.dll … etc.

November 8, 2010

Macro Scheduler 12.1.1 Available

Filed under: Announcements — Marcus Tettmar @ 3:24 pm

Macro Scheduler 12.1.1 is now available with the following fixes since my last update announcement:

  • Fixed: TrayIcons, XL, Telnet and ADO objects being destroyed at end of event handler subroutines
  • Fixed: FTP Status window in FTPDelFile, FTPRemoveDir, FTPMakeDir, FTPRenameFile not being closed at end of operation
  • Fixed: A macro containing a dialog called with the Macro> command will not show the dialog

Workflow Designer and the SDK have also been updated to the same MacroScript version.

Registered Downloads/Upgrades | Evaluation Downloads | New License Sales

November 3, 2010

Is a File Ready? Waiting for a File Process to Complete.

Filed under: Automation, Scripting — Marcus Tettmar @ 4:11 pm

In the comments to my last post Richard asked how we can wait for a process to finish updating a file.

In my reply to Richard I point out that most of the time we can use a visual cue. Where possible this is the approach I would use. Usually an application would present some kind of visual cue when the file operation finishes. A dialog box might appear, or disappear, an object may become enabled or disabled, some text may appear on the screen, etc. We might be able to use commands such as WaitWindowOpen, WaitWindowClosed, WaitWindowChanged, WaitScreenText, WaitScreenImage, WaitCursorChanged, WaitPixelColor, or WaitRectChanged. Or we might even create our own wait loop which checks for some value or property. I mention this approach in Top Tips for Reliable Macros.

Unfortunately there are sometimes scenarios where there is no visual cue and we have nothing we can “see” which tells us the file operation has completed.

If the file is locked by the application that is writing to it, we could create a wait loop which checks to see if the file is still locked or not.

How might we achieve that? Well, why not just try to read from the file. If the file is locked we’re not going to be able to read it right? So we could just do:

Label>wait_file
ReadLn>file,1,res
Pos>##ERR##,res,1,pErr
If>pErr>0
  Wait>0.2
  Goto>wait_file
Endif

This will work for any kind of file.

Of course this assumes that the file is locked for reading by other processes.

It’s possible that the application locks the file only for writing. In that situation we could use WriteLn to attempt to write an empty string to the file:

Let>WLN_NOCRLF=1
Label>wait_file
WriteLn>file,res,{""}
If>RES<>0
  Wait>0.2
  Goto>wait_file
Endif

But that’s a bit invasive in the instance that the file IS available as although we’re writing nothing, we’re still modifying it so updating it’s timestamp.

We can get a bit more control over this with VBScript where we can attempt to open a file for appending without actually modifying it:

VBSTART
Function TestFile(filename)
   Set oFSO = CreateObject("Scripting.FileSystemObject") 
   On Error Resume Next 
   Set f = oFSO.OpenTextFile(filename, 8, True)
   TestFile = Err.Number 
End Function
VBEND

Let>file=C:\files\bmp.bmp

Label>wait_file
VBEval>TestFile("%file%"),fRes
If>fRes<>0
  Wait>0.2
  Goto>wait_file
Endif

All the TestFile function does is try to open the file for appending, and if an error occurs it returns the error code. So if we get zero back, there’s no error and the file must be available for writing and therefore not locked.

Don’t be put off by the fact that this uses the OpenTextFile method. It will still work with any kind of file. We’re not actually going to attempt to modify it. We’re just trying to see if we can open it. So the file type is unimportant.

Note that in these samples I haven’t checked for any specific error code nor have I checked for the existence of the file first – I’m assuming any error means the file isn’t available. An error will also be returned if the file does not exist, so you’d probably want to use IfFileExists first. You might even want to put FileExists in a loop so that you can wait until it exists.

Note also the small wait in each loop. This is just to make sure the loop isn’t so tight that it hogs CPU. Better to be nice to the system and give other processes a chance to breathe.

November 2, 2010

Waiting for the Clipboard

Filed under: Automation, Scripting — Marcus Tettmar @ 2:58 pm

Today I was helping someone who was wanting to write a script to take screen-shots from one application and then paste those screen-shots into Microsoft Excel.

Initially things weren’t working reliably because the script didn’t factor in the time taken for the large bitmap of a screen-shot to exist in the clipboard after pressing the print screen button, before attempting to paste into Excel. E.g. consider:

Press Print Screen
SetFocus>Microsoft - Excel*
Press CTRL
Send>v
Release CTRL

The above is probably going to fail most of the time because a screen shot is a large bitmap and is going to take some time to arrive on the clipboard, but the script above performs a paste in Excel immediately after pressing print screen. The print screen key being depressed and the clipboard containing the bitmap are not the same thing.

While we could have just said “wait 5 seconds” and that would probably have been fine for evermore, it isn’t very sensitive and wouldn’t be ideal for a script that needs to run as fast as possible. Ideally we only want to wait until we know the bitmap is in the clipboard.

Text is usually smaller than a bitmap, but for large text items one way to make things bulletproof is to do something like this:

PutClipBoard>dummy

SetFocus>source_app_title
Press CTRL
Send>c
Release CTRL

Label>wait_for_data
Wait>0.2
GetClipBoard>clipdata
If>clipdata=dummy
  Goto>wait_for_data
Endif

By putting a known value onto the clipboard in the first place we can then have a little loop which keeps checking the clipboard until the returned value is not our known value. We then know our CTRL-V has worked and that we can safely paste to the target application.

But how can we do the same thing when the clipboard data is an image? The above won’t work because GetClipBoard won’t return anything for non-textual data.

Well, Windows has a function called IsClipboardFormatAvailable which will allow us to determine what kind of data is on the clipboard. So we could use this in a similar way to above to see if the clipboard contains a bitmap or not. Like this:

Let>CF_BITMAP=2

Let>haveBMP=0
PutClipBoard>dummy

Press Print Screen

While>haveBMP=0
  LibFunc>user32,IsClipboardFormatAvailable,haveBMP,CF_BITMAP
  Wait>0.2
EndWhile

We could then paste it somewhere:

SetFocus>Document - WordPad
Press CTRL
Send>v
Release CTRL

It’s always nice to wait only as long as we have to and it makes the script more reliable and portable.