Have you ever tried to send a piece of Macro Scheduler code (or any other code for that matter) to someone by email or instant messaging, or even in a forum, and found that it gets mangled? HTML strips leading spaces, characters get stripped or changed, and special characters get inserted and so on. Even when the code works it ends up looking ugly and is hard to read.
But now you can use our Code Snippets tool. You can access it via your Forum account and you’ll find it in the forum nav menu (top right of forum pages). Or go direct here (you’ll need to be logged into the forums – you can create an account for free if you don’t already have one).
Simply give your snippet a title and paste your code into the box. When you save it you’ll be given a special link which you can give to anyone, via email, forum, instant messaging, or however you like, and you can be sure that the recipient will be able to see your code, all nicely formatted and syntax highlighted. They can copy and paste it safely into a Macro Scheduler script without it being messed up, or they can view the raw file.
Here’s an example: http://www.mjtnet.com/snip.htm?g=533575bab6f58
You’ll also get a special forum embed code. Use this if you want to paste your code into a forum post. Instead of pasting your code, paste the embed code and then when your post is viewed it will display a nicely sanitized version of your code.
Over on the right of the Code Snippets page you’ll also see a list of snippets you’ve already made. If you need to grab the link or embed code just visit a snippet page and you’ll see the link and embed code at the bottom.
So, now, if you’re sending pieces of code to our support desk via email or live chat, to a friend or colleague or in the forums, please use Code Snippets.
Note that Code Snippets, as it’s name implies, is designed for small scripts and code examples. If you need to send a huge script to someone it’s probably best to send the raw script file as an attachment.
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
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.
Someone was asking how to get a list of subfolders. You can do that with the GetFileList command by setting GFL_TYPE to 1. That gives you the folders in the specified path. But it turns out he wanted a recursive list – i.e. one that drills down through all levels.
To do that you need a recursive function. In Macro Scheduler we can do this by making a subroutine call itself. I’ve added an example on the Scripts ‘n Tips forum. Here.
For a bit of fun go to Google and search for “recursion” and see what you get:
Macro Scheduler 14.1 is now available.
Here’s a summary of changes in Macro Scheduler 14.1:
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.
Do you know what code signing is?
Want to prevent those “unknown publisher” warnings that might pop up when you or your clients download and run your compiled macros?
Then you need a Code Signing Certificate to sign your .EXEs with.
It’s not always when downloading files that you might get this warning. Recently a customer found a .EXE that he was launching from a reporting tool was producing this warning. It seems the reporting tool was checking for a code signing signature. Virus checkers including Windows 8′s SmartScreen filter will also look upon signed apps more favourably.
In forum post “Is it a Macro Recorder, is it an Automation Tool, or ….” Antonius asks how we can make Macro Scheduler more popular. This is not the first time I’ve been asked this.
The easiest and quickest way to help is to Share. At the top right of every page of the website are some “Social Sharing” buttons.
Click on your favourite social networking site (e.g. Facebook, Twitter or Google+) to share www.mjtnet.com with your followers. Click the +Share link to get a list of other places you can share to.
Or you can use this link here:
Clearly we’d LOVE it if you shared. All businesses, especially small ones, need new customers. But apart from that we want to build the user community for the benefit of everyone. More users means more forum peers, more product ideas and an even better Macro Scheduler. So, go on, get sharing
Just been asked how to read from the system event log (what you see in Windows Event Viewer) using Macro Scheduler.
So I’ve taken that code and modified it slightly to return a list of all entries for a given event code. Here is the script:
Although I’ve added code to allow you to retrieve ALL events I would not advise it as that could take A. VERY. LONG. TIME.
When you tell people about Macro Scheduler how do you describe it? Do you call it an automation tool, a macro recorder, a script language, a data entry tool, an interface builder, a trained monkey, or something else altogether?
I’d be interested to know.
To me Macro Recorder suggests only a tiny part of its capabilities, but it’s a useful and popular term.
An automation tool sounds more encompassing but “automation” can mean different things to different people.
IBM and SAP use “automation” to refer to the interconnected nature of their Enterprise solutions, connecting data across the entire organisation. But to me – and Macro Scheduler – automation is something more robotic: automation of a more specific set of human activities.
This kind of automation requires a tool box containing many tools, one of which might be the macro recorder.
Does it matter? Not if you’re using it and benefiting from it, no, probably not. But in getting the word out, explaining what it is to people and from a marketing point of view, it’s more tricky.