November 25, 2014

How to Trigger an Action if the Number of Connected Monitors Changes

Filed under: Automation,Scripting — Marcus Tettmar @ 9:57 am

Today I was asked if Macro Scheduler can trigger an action if the number of connected monitors changes. Yes, all we need is a way to determine how many monitors are connected to the system. VBScript is one way to do that. So then all we need is a loop that constantly checks this value. So we end up with something like this:

October 14, 2014

The Macro Scheduler MacroScript SDK in Python

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

Did you know there was a Macro Scheduler SDK? It allows you to run Macro Scheduler code from right within your own apps. You can run and interact with MacroScript code within VB, C++, C#, Delphi, VBScript … or any other programming language which lets you use a COM object or Win native DLL.

It even works in Python. Here’s a small example which uses the screen image recognition functionality to find and click on the Windows Start button:

Another slightly more complex example which opens Notepad and types into it. It also demonstrates how you can call chunks of code at a time instead of all at once and set and get the value of script variables during execution. It also gets the result of the script set via MACRO_RESULT:

More information about the MacroScript SDK can be found here.

A number of customers have used the SDK to build macro-ing capabilities into their own products and/or create tighter integrations between their own software and automation routines using MacroScript.

If you’re interested in trialling a copy or getting pricing info drop us a line.

August 8, 2014

Detect Which Web Page IE Is On – Keep It Simple

Filed under: Automation,Scripting — Marcus Tettmar @ 9:43 am

Today we had two different support requests asking how to have a Macro Scheduler macro determine which page IE is on.

One person was asking about using Image Recognition for that. You could also use the IE functions to examine the HTML or look for the existence of a specific HTML element.

You could do one of those, sure, but I think that’s over complicating things.

My motto is “keep things simple”.

IE’s Window Title adopts the page title of the web page it is displaying. IE also shows the URL in the address bar. So why not just look at one of those. Like this:

//Two simple methods to see which page IE is at.

//Method One - Just look at the window title
IfWindowOpen>Bing - Internet Explorer
  //Bing is open - do this
Else
  IfWindowOpen>Google - Internet Explorer
     //Google is open - do that 
  Endif
Endif

//Method Two - Look at the Actual URL in the URL bar - I used the Wizard to get this code and then altered the window title to make it a substring match
UIGetValue>- Internet Explorer*,{"Address"},curVals,Positions,nHeight
Position>google.co.uk,curVals,1,pGoogle
If>pGoogle>0
  //must be at google
Else
  //must be somewhere else
  Position>bing.com,curVals,1,pBing
  If>pBing>0
    //must be at bing
  Endif
Endif

June 19, 2014

Automating Facebook and other Web Apps via Zapier

Filed under: Automation — Marcus Tettmar @ 12:09 pm

A while back someone was looking for a way to post from a macro to a facebook page. A few methods were mentioned. There’s another one which is easy and reliable and that is to use Zapier.com. I’ve made a video here to demonstrate how to set it up:

But this demonstrates a lot more potential than just posting stuff to Facebook. Facebook is really just an example. Zapier supports a huge array of other web apps, including help desk systems, CRM systems, email, google docs, popular accounting platforms and a lot more besides. The same principle as used in my video above can be used for those too. So if for example you wanted a macro to create an Invoice in Freshbooks. No problem.

So instead of having to automate the front end of these web apps or spend the time or pay a programmer to work with their API directly, Zapier is a simple solution which sits in the middle. They have a free plan too.

It would also be possible to work the other way and get data OUT of web apps. There are a number of ways to do that including writing to a MySQL database (which Macro Scheduler could read) and saving text/CSV files to a dropbox folder (which Macro Scheduler could read), sending emails (which Macro Scheduler could retrieve) and so forth. Maybe that’s another video.

I’m sure you can come up with some other cool ideas. How about: Running a macro via SMS.

You get a Twilio account with a twilio number. Set up a ZAP which responds to a new SMS sent to your Twilio number and saves a file in a dropbox folder. Have the body of the message saved to the file. You have a macro which is set up on a new file trigger.

So when Macro Schedueler sees a new file in the dropbox folder it runs a macro, which reads the body of the newest file and then parses out the name of the macro it needs to run …

Now you can run macros remotely on your machine from your mobile phone via SMS 🙂

Load Testing – Measuring Elapsed Time

Filed under: Automation,Macro Recorder,Testing — Marcus Tettmar @ 12:02 pm

In a support email recently I was asked how to record a macro to perform load testing.

While you could certainly use the macro recorder for much of the process, in most cases you are probably going to want to insert some code to make the macro more dynamic in waiting for events to complete. Your load testing is going to slow things down and what you want is to measure how long things take. So you’ll need to be sure you’re waiting for “readiness” and calculating how long that took.

The macro recorder by its very nature records the firing time between distinct events like mouse clicks and keystrokes exactly as it happened at play back. It does however insert “WaitWindowOpen” commands when new windows appear and these will be dynamic – they will wait however long is needed for windows to open and close.

But more often than not you’ll want other forms of waiting. My personal recommendation is to use WaitScreenImage to wait for a visual cue on the screen. This is closely analogous to how a human uses the application – she uses her eyes to see what’s on the screen and determine “readiness”.

If you’re load testing then you’re probably going to run lots of macros – or virtual users – at the same time and are going to slow things down. This is exactly what you want to do – you want to see what the effect of adding more users is – and you’ll need to measure elapsed time. So you’ll need the macro to wait exactly as long as necessary.

The easiest way to do that is with Image Recognition. By all means use the macro recorders to record the simple bits – the bits that send keystrokes into fields. Or use the UI functions and the handy Find Object Wizard.

Also use the Screen Image Recognition wizard to record your waits. It’s real easy. Just capture the thing on the screen you want to wait for and it will spit out the code to do that.

So once you’ve done that you have a macro which will carry out the process and wait for things to complete and be ready before continuing. Now you will want to gather statistics to see what the elapsed times are and compare with different scenarios.

You might do this simply by looking at the log file for the macro. The log file outputs the time each command executed. So you could calculate the elapsed time between starting a step and when it completed. I’ve known customers simply open the log files in Excel and add their own formulas.

But I would make use of the Timer function to have the script itself measure the elapsed time of specific events. You might then output this elapsed time to an Excel or CSV file or store it in a database. It’s up to you.

Here’s a simple bit of code which sets a timer, runs Notepad, waits for it’s main window and then calculates elapsed time, storing it in a CSV file.

//start the Timer
Timer>startTime

//Run Notepad as an example
Run>notepad.exe
//wait for it to be ready
WaitWindowOpen>Untitled - Notepad

//How long did that take?
Timer>endTime
Let>elapsed=endTime-startTime

//elapsed is in milliseconds - write it to our CSV file
WriteLn>c:\temp\test_1.csv,wRes,STEP1;%elapsed%

This is really just to show you how the Timer function allows you to measure elapsed time – you’ll likely have a bit more going on and if “readiness” is not signalled by a new window as it is here then WaitScreenImage might be a better option.

March 27, 2014

Why doesn’t SHIFT-ESC stop my compiled macros?

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

You might find that when you run a compiled macro and you also have Macro Scheduler running, Shift-Esc – the default stop key sequence – doesn’t stop the compiled macro.

This is because the stop key sequence is a system wide hot key. And system wide hot keys can only be registered for use by one application at a time. So if Macro Scheduler is already running when you start your .exe the .exe is unable to register Shift-Esc because Macro Scheduler already has it.

Of course when you deploy your .exe to people who don’t already have Macro Scheduler – which is usually the case – there won’t be any problem because Macro Scheduler won’t be running and so your .exe is able to register the Shift-Esc hot key.

But what if you want to define your own stop hot key, or you want to give your users the option of setting it? Well what you need is a KEY_DOWN event handler:

//CTRL-Z is stop key
OnEvent>KEY_DOWN,VK90,2,doExit
Let>paused=FALSE

//sample code here ...
Wait>20
MessageModal>hello

SRT>doExit
   Exit>0
END>doExit

Here we have set up a key down event handler for CTRL+Z. VK90 is Z and 2 is the modifier key for CTRL. See the OnEvent help topic and Virtual Key Codes List.

The event handler basically sets up a concurrent thread that is running all the while the main script is running. This allows it to respond to events such as this KEY_DOWN event. So when you hit the specified key sequence – in this case CTRL+Z, the doExit subroutine runs and all that does is call the Exit function which terminates the script.

You could be smarter and ask the user if he really means he wants to exit:

SRT>doExit
   Ask>Are you sure you want to exit?,ynExit
   If>ynExit=YES
      Exit>0
   Endif
END>doExit

When you compile the macro there is an option to disable the standard Shift-Esc sequence. So you could do that to completely replace the stop key system with your own custom one using your OnEvent.

Consider an INI file and possibly another config script using a custom dialog to allow the user to set his own stop key sequence. Other apps could already be using it. My CTRL+Z example is probably not ideal as although it is used in Linux to suspend the current process it is usually the short cut for Undo in Windows.

March 17, 2014

Macro Scheduler 14.1 Available

Filed under: Announcements,Automation,Macro Recorder — Marcus Tettmar @ 12:18 pm

Macro Scheduler 14.1 is now available.

Here’s a summary of changes in Macro Scheduler 14.1:

  • New UI Automation functions for manipulating “Accessible” objects (UI Automation Elements).
  • New FindObject Wizard for locating objects, detecting accessible elements and outputting code to manipulate them.
  • Support for HTML email in SMTPSendMail
  • New HTMLViewer component for custom dialogs
  • Macro Recorder speed/reliability improvements
  • Other new functions and improvements.

The most notable addition here is the support for UI automation elements.  What’s this all about?

Well, this makes use of Microsoft’s Active Accessibility framework which allows application developers to expose UI elements to other applications.  It was originally designed to help accessibility tools like screen readers and also for automated software testing applications.

Essentially it means that the controls of applications – the UI elements such as buttons and form fields – can be more easily identified and manipulated.  Controls can be identified by name.  Here’s a short video showing this in use:

Bear in mind that what you can do with this will vary from application to application and what is possible will depend very much on what the application developer has exposed. If a developer hasn’t specifically named elements or knowingly used Accessibility, Windows will in many cases – and assuming a standard windows UI framework has been used – expose the controls anyway and will name objects based on their captions and labels.

To make it easy to identify elements we’ve added the Find Object Wizard which will show you the Accessible object beneath the cursor and let you create code to manipulate it (e.g. click it or set it’s value).  So using this you can experiment with what is possible with the application you want to automate.   Please let us know in the forums which applications you have used this with.

Assuming this new functionality proves useful, expect more features and improvements in future.

Trial Downloads | Registered Downloads | Version History

February 20, 2014

Problems Sending Keystrokes to Citrix?

Filed under: Automation,Scripting — Marcus Tettmar @ 5:10 pm

If you’re seeing odd results when trying to send keys to Citrix Receiver windows try going into legacy mode:

Let>SK_LEGACY=1
Send>some text

October 3, 2013

Automating Google

Filed under: Automation,Scripting — Marcus Tettmar @ 1:59 pm

This has come up a few times lately so I thought I’d post it here.

One or two people have been asking about writing a Macro Scheduler script that performs a Google search and pulls back the resulting URLs. They have discovered that trying to automate Google can be awkward because of the dynamic nature of the page. As soon as you type in the search box the page changes because it is updating in real time.

Some people suggested using HTTPRequest to get the page content directly and then parse it with RegEx. This can be done but is also tricky because you’re getting back all the dynamic code and other stuff like adwords ads etc and it is hard to find the right patterns.

There’s an easier way. Use their API URL instead. E.g.:

http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=Apple%20Pie&rsz=large&start=1

This performs a search for “Apple Pie”. Try it in your browser and you’ll see the content is less cluttered and it is easy to parse. It returns 8 results. For the next 8 you would change the start parameter to 9, and so on.

So here’s a simple example script which takes a search term, specifies how many results to get, extracts the URLs and writes them to a text file:

September 26, 2013

Macro Scheduler in the Winter Olympics

Filed under: Announcements,Automation,Macro Recorder — Marcus Tettmar @ 12:29 pm

Macro Scheduler on Skis? No, not exactly. But your favourite automation software and macro recorder will apparently be helping behind the scenes at the Winter Olympics next year in Sochi.

I received this message from Stefano Frattini, DT Manager at Olympic Broadcasting Services SL, yesterday:

You’ll be happy to know that a small Macro Scheduler script will be running on a service channel machine at the Sochi Olympics next year. The script is controlling the download, verification and sorting of weather information files which actually feed a TV channel from OBS (Host Broadcaster) called Olympic Weather Channel. This channel is distributed to all the Rights Holder Broadcasters during the SOCHI Olympic Games.

« Newer PostsOlder Posts »