Marcus' Macro Blog

Mostly tips, tutorials, articles and news about Macro Scheduler & Windows Automation

Archive for the ‘General’ Category



Associating a File Extension with a Compiled Macro

Wednesday, June 23rd, 2010

I have a few scripts which perform actions on files. Rather than have the script ask me what file to use, it is easier to associate the file type with the script so that I can just double click on the file (or right click and choose “Open with”) in Windows Explorer.

For this to work the script must first accept a file on the command line. Here’s a really simple script which reads the content of a file passed into the script with the “thefile” command line parameter:

ReadFile>%thefile%,fdata
MessageModal>fdata

If you were to compile this script and then pass thefile on the command line it would read in the file content and display it in a message box:

c:\path\myexe.exe /thefile=c:\somefile.mjt

Now, if we create a file association for .mjt files we would only need to double click on the .mjt file to have it open in the exe.

The easiest way to create a file association for a file that does not already have one is to just double click on the file in Windows Explorer. Then when asked choose to select from a list of installed programs and on the next dialog click on the “Browse” button to locate your executable.

If the file extension is already associated with other applications then right click on the file and choose “Open With” and then “Choose program…”, then UNCHECK “Always use the selected program to open this kind of file” and click on “Browse” to locate your executable.

Initially this won’t quite work. We need to make a small change, as this creates a mapping in the registry which looks like this:

“c:\path\myexe.exe” “%1″

We want to change it to:

“c:\path\myexe.exe” /thefile=”%1″

So after creating the file association via Windows Explorer we need to make a small registry change:

1. Fire up RegEdit.exe (Start/Run and then type regedit.exe)
2. Open HKEY_CLASSES_ROOT
3. Search for your exe name to find the “c:\path\myexe.exe” “%1″ entry
4. Make the change as above, changing the “%1″ to /thefile=”%1″

Now, when you double click the file (or right click/Open with) it will launch your exe, with the filename passed to it in the “thefile” parameter.

You could actually code the script in such a way that you don’t need to do the registry change. You could parse the COMMAND_LINE system variable to get the file from the command line, without requiring a custom parameter name. This is discussed in this forum post which talks about being able to drag and drop a file onto a script.

If you want to create the file association programmatically, take a look at what registry entries are created by Windows when you do it manually. Then you can use the registry functions to achieve the same. E.g. this script associates .why files with the “c:\where\why.exe” executable expecting the file in a parameter called “thefile”:

RegistryWriteKey>HKEY_CLASSES_ROOT,.why,,why_auto_file
RegistryWriteKey>HKEY_CLASSES_ROOT,why_auto_file\shell\open\command,,"c:\where\why.exe" /thefile="%1"

[Post to Twitter] Tweet This

Weekly Forum Round-up

Friday, May 21st, 2010

I thought I might start a weekly round up of some of the Macro Scheduler forum posts that caught my eye during the week. Not everyone gets a chance to browse the forums all the time, so it might help to link to some here. Then those that subscribe to the blog via RSS/Email will see them and they’ll also show up in Macro Scheduler’s News Feed window.

The forums are quite active but I won’t link to every little discussion or request for support – just those that demonstrate a new feature, or work as a “how to” or anything else that I think could be useful. We’ll see how it goes.

So here’s my list for week ending 21st May 2010:

How to trim spaces from the ends of, or within, a string

A Progress Bar Demo using Macro Scheduler 12

How to make a custom dialog minimize to the task bar

Putting a status bar with multiple panels on a custom dialog

Finding a drive based on its label (volume name)

Getting the HTML source of a page using WebRecorder

Running Automated Testing scripts in the background via VMWare

[Post to Twitter] Tweet This

Sharing and Synchronizing Macros

Thursday, May 20th, 2010

A new feature in Macro Scheduler 12 is the ability to easily share macros with other people on your network, or between desktops.

It has long been possible to work outside of the Macro Scheduler interface and indeed many people already do this. You can use the standalone editor and run or edit macro script files (.scp) directly from Windows Explorer. So to share script files you can store them in a network folder which each person in your team can access.

But until now that had some limitations. Firstly you would have to work outside of the Macro Scheduler interface and secondly, until version 12, scripts weren’t opened exclusively. So if two people were working on a script at the same time the last person to save would overwrite the changes made by the first. Until now Macro Scheduler was not built with network sharing in mind. And of course if you wanted to apply a schedule, trigger, or hot key to a shared macro you would need the Macro Scheduler interface. So would need to import it. Therefore any time it was changed you’d have to re-import it again.

Linked Groups and Exclusive Opens

With Macro Scheduler 12 you can now create “Linked” macro groups. Version 12 also makes sure that when you open a script for editing it is opened exclusively. This means the file is locked and no one else can open it until you’re done.

To create a Linked Group, create a new macro group as you would normally, set the path of the group to point to a network share, and check the “Create Linked Group” box. Give it a name and click OK.

Any macros already in the folder will show up immediately. And if you create a new macro in that group (or move a macro to it) other people with a group linked to the same folder will see those macros too.

So Linked Groups are useful where you want to easily share macros between members of your team or between two desktops – e.g. your desktop and your laptop.

You could also share macros between a developer and several users and prevent the user from being able to edit them by using a network share that you can write to but they only have read only access to. The users would be able to run the macros but not edit them or create new ones in that group.

Note that at present to delete a macro from a Linked Group the file needs to be deleted from the folder using Windows Explorer. This is partly to avoid accidental deletes and to prevent people from moving linked macros. We are considering ways of improving on this in future so that linked groups can be administered more easily within Macro Scheduler. It’s early days for Linked Groups and I’m sure as more people start to use them ideas will start flowing in. So if this is something that becomes popular expect improvements over time.

[Post to Twitter] Tweet This

Using an Old Version? Time to Upgrade for Vista/Win7 Support.

Friday, April 23rd, 2010

If you’re using an old version of Macro Scheduler, especially version 8 or lower, and like many others, you or your company are considering upgrading your Windows operating system to Vista or Windows 7 soon then you will need to consider upgrading Macro Scheduler too.

Windows 7 adoption rates are outpacing those of Vista fast and many companies are planning on going straight from XP to Windows 7. Already Windows 7 has over 15% market share with over 90 million licenses sold as of March 2nd.

Version 8 of Macro Scheduler was superseded before Windows Vista came along. And Vista brought with it some changes that required us to make changes to Macro Scheduler. So Macro Scheduler v9 was the first version that fully supported Vista. The latest version supports Vista and Windows 7 fully and is listed at Microsoft.com as a “Windows 7 Front Runner” application.

One of the things that Vista introduced were the thumbnail windows that appear when you hover over a task bar icon. These have the same title as the application’s main window. So in Macro Scheduler 8.0 and lower you will run into a problem where your SetFocus lines and other window functions find this thumbnail window before the main window and prevent your scripts from working properly.

Starting with Macro Scheduler 9.0 (in 2007) we made the window functions ignore these new thumbnail windows to prevent this problem. We also had to make some changes to the macro recorder. Older versions may not be able to record under Vista without running Macro Scheduler as admin.

So if you’re still running Macro Scheduler 8 or below then even if you have no plans to change your macros, you’re going to need a newer version when your operating system is upgraded to Windows 7.

Furthermore, we can’t support old versions forever and with the release of version 12 we will be discontinuing support for versions 8 and lower. Since version 9.0 was the first version that properly supported Vista and above we can only really continue to provide support for this version and onwards.

Version 12 offers even more Vista/7 functionality including a reliable AutoLogon mechanism that works in Vista/7/2008 to allow you to schedule macros to run even when Windows is locked or logged out.

So now is the time to upgrade. And if you buy or upgrade to v11 now, we’ll give you a free upgrade to v12 when it is released in a few weeks.

So there’s really no need to wait.

For a summary of new features in v12 click here and here.

The best way to upgrade is to log into your registered account and click the upgrade links. Any problems accessing your account email us.

Consider adding maintenance to your order as well. This will ensure you continue to get all future upgrades and new features automatically at no extra cost. Maintenance is the easiest way to ensure your software stays up to date with all the new Windows releases.

Take a look at the Macro Scheduler history list to see how many improvements there have been since version 8:
http://www.mjtnet.com/mswhatsnew.htm

[Post to Twitter] Tweet This

GearHead Hero Movie

Tuesday, April 20th, 2010

Have you seen the movie?

http://en.tackfilm.se/?id=1271773406310RA59

:-)

[Post to Twitter] Tweet This

Screen Magnifier In Only 34 Lines of Code

Monday, March 8th, 2010

Check out this screen magnifier, written by Dick Lockey in only 34 lines of Macro Scheduler code.   Paste it into a macro, hit run and then as you move the mouse around your screen you’ll see a 5x magnification of the cursor area.

Dialog>Dialog1
   Caption=5X Magnify
   Width=800
   Height=500
   Top=500
   Left=48
EndDialog>Dialog1
Show>Dialog1
  LibFunc>user32,GetDC,HDC1,Dialog1.handle
  LibFunc>user32,GetDC,HDC3,0

Label>Loop
  GetDialogAction>Dialog1,res1
  If>res1=2
    Exit>0
  EndIf
  GetCursorPos>CurX,CurY
  Sub>CurX,80
  Sub>CurY,50
  Wait>0.01
  LibFunc>Gdi32,StretchBlt,SBres,HDC1,0,0,800,500,HDC3,CURX,CURY,160,100,13369376
  GoSub>DrawLine,Dialog1.handle,1,0,390,250,410,250
  GoSub>DrawLine,Dialog1.handle,1,0,400,240,400,260
Goto>Loop

SRT>DrawLine
  LibFunc>user32,GetDC,HDC,%DrawLine_var_1%
  LibFunc>gdi32,CreatePen,Penres,0,%DrawLine_var_2%,%DrawLine_var_3%
  LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
  Libfunc>gdi32,MoveToEx,mtres,HDC,%DrawLine_var_4%,%DrawLine_var_5%,0
  LibFunc>gdi32,LineTo,ltres,hdc,%DrawLine_var_6%,%DrawLine_var_7%
  LibFunc>gdi32,DeleteObject,DOres,Penres
  LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawLine

Yes, as Dick Says, you get one of these with Windows. But it’s kind of cool to see you can do the same thing with Macro Scheduler, and the code might come in handy elsewhere.

Enjoy.

[Post to Twitter] Tweet This

Choose Your Web Browser

Thursday, March 4th, 2010

One of my Windows XP systems installed an automatic update last night when I shut it down.  This morning I was presented with this:

Windows EU WebBrowser Choice

As I understand it this is as a result of an EU competition law decision.   Is this a good thing or a bad thing?

On the one hand it seems a waste of money and illogical.

I’m no fan of IE, but why shouldn’t Microsoft build a web browser and make it part of their operating system?  Should the EU force them to offer a choice of text editors, calculators, paint programs and calendar applications too? Where should it end?

Plus, yet another dialog like this is surely going to confuse the ordinary user.  Many have no idea what a “web browser” is and just call it “My Internet” or “Google”.  The dialog preceding the one above has to go to the trouble of explaining what a web browser is.  And isn’t the user just going to take the first option anyway?  In which case should the EU force Microsoft to make IE8 something other than the default option?

But then if I were trying to sell a web browser I guess I would welcome this decision. It might give me a little extra exposure.

What do you think?

[Post to Twitter] Tweet This

Seeking Industry Partners

Tuesday, February 16th, 2010

Are you a contractor, consultant, freelancer or value added reseller who knows and uses Macro Scheduler and works in a specific industry, like Health Care, Education or Manufacturing? If you are I’d like to hear from you.

I’m looking at opportunities for Macro Scheduler in vertical markets and would like to find people with industry experience who can add value and help us promote and support Macro Scheduler in their sector. We need help identifying the key systems and applications used in these markets and creating macros and solutions for them using Macro Scheduler.

It doesn’t really matter what industry you work in. Whatever your vertical market, if you’re a Macro Scheduler user with industry knowledge and the flexibility to explore opportunities, please get in touch.

[Post to Twitter] Tweet This

FTP Uploader – Upload Files From Explorer

Friday, February 5th, 2010

Phil Pendlebury has written a really handy little tool for quickly uploading files from Windows Explorer, and he’s built it using Macro Scheduler.

With his FTP Uploader tool installed you can right click on any file and select Send To->FTP Uploader to quickly upload it to any FTP site.

It will remember the FTP server settings for you and you can choose which FTP settings to use. If the uploaded file has a public web URL the tool will also create the URL for you and put it on the clipboard. Handy for sending people links to file, or uploading images and other files for use in forums.

FTP Uploader

You can download the tool and get the source code here.

I’m often uploading files to our FTP server to send to people, instead of relying on Email attachments. This tool will make short shrift of that. Thanks Phil!

[Post to Twitter] Tweet This

Running Macro Scheduler Macros over the Web Via PHP

Friday, January 29th, 2010

Here’s a quick and simple proof of concept for running Macro Scheduler macros via the web and having their output displayed in the user’s browser:

Running Macro Scheduler Macros Over the Web Via PHP

The screenshot shows the PHP script, Macro Scheduler script and Internet Explorer being used to run the macro.

1) If you don’t already have a Windows based web server with PHP running, download and install WAMPServer. It’s easy.

2) Create a simple PHP script which takes an EXE name as a parameter and any parameters you want to pass to it. The following script will run EXEs that are in the c:\wamp\ folder, passing in any parameters provided and will dispay the EXEs output.

<?php
$exe = $_GET['exe'];

$dir = "c:\\wamp\\";

$parms = "";
foreach($_GET as $key=>$val) {
  $parms .= "/$key=$val ";
}

echo shell_exec("\"$dir$exe\" $parms");
?>

3) PHP’s safemode must be disabled for this script to work.

4) Create a Macro Scheduler macro and use SOWrite or SOWriteLn to output information. Compile it with the “Create Console App” option checked. Compile the EXE (or copy it) to the c:\wamp\ folder.

5) Now the macro can be executed via the web using http://servername/runmacro.php?exe=my.exe&parm1=value&etc=… which could be a link or entered into the browser directly.

6) Consider adding further security to the script to prevent anyone running any EXE on your server, or putting it in a password protected folder. I’ll leave that to you.

Macro Scheduler Enterprise comes with the msNet Remote Controller which includes a CGI module for running Macro Scheduler macros via web servers.

[Post to Twitter] Tweet This