How to make Macro Scheduler run macros in response to HTTP requests
Setup and Test with msNetGui
We need to make Macro Scheduler listen for HTTP requests. We can do this using the Remote Controller add-in which ships with the Enterprise Pack. The steps below walk through installing, configuring and testing the Remote Controller with Macro Scheduler running on your local machine.
- First install the msNet Remote Controller package which ships with Enterprise Pack.
- In the msNet program folder locate ServerSetup.exe. Run this on your local machine and install into the Macro Scheduler program folder as prompted.
- When asked for a port number enter something that is not already being used. E.g. 2222. You can leave password blank for now.
- Restart Macro Scheduler.
- Create a simple macro to test with and save it as 'remoteTest1':
Let>MACRO_RESULT=<p>hello %fname% %sname
- Now let's first test with msNetGui.exe - which you'll find in the msNet program folder.
Enter 127.0.0.1 in address, 2222 in Port Number, the macro name 'remoteTest1' or whatever you called the above macro. In Parameters enter /fname=fred /sname=bloggs:
Hit Run and switch back to Macro Scheduler. You should see that the macro is running and a message has appeared saying "Fred Bloggs". Close that message and switch back and you should now see <p>hello Fred Bloggs</p> in the Result pane.
Note how we are passing values to the variables fname and sname.
If you get a connection error and you're running on your local machine with 127.0.0.1 then the most likely issue is that the port number is not available or your firewall is blocking Macro Scheduler. Try running ServerSetup again and try a different port number, check your firewall and make sure you're installing into your Macro Scheduler program folder and restarting Macro Scheduler afterwards.
Creating an HTTP Get Request
Hit enter and switch back to Macro Scheduler and you should see the macro is running. Confirm the message box and switch back to your browser and you should see the html appear in the browser. Note how we are setting the variable values via query string parameters.
However, you probably want to get rid of that modal message box. In a real world scenario it is unlikely you'd want something waiting for user input and blocking the process from continuing. We just put that in there so that we could see something happening during testing. Also, of course, you would usually have the macro running on a different machine, so would be referencing a different IP address. When you do that you'll want to make sure the IP address is reachable and the port is unblocked for TCP traffic in the firewall.
Other language examples
import requests response = requests.get("http://IP_ADDRESS:2222/remoteTest1?fname=Fred&sname=Bloggs")
$response = file_get_contents("http://IP_ADDRESS:2222/remoteTest1?fname=Fred&sname=Bloggs");