Concurrent macros - possible?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
klcmay
Newbie
Posts: 16
Joined: Sun Jun 01, 2008 10:12 pm

Concurrent macros - possible?

Post by klcmay » Mon Oct 05, 2009 10:27 am

I'm trying to do the following:

Computer 1 is running a long running macro doing some GUI processing. Sometimes user input is required so it sends data to a second PC where a real user has a simple interface, say a yes/no dialogue.

When the user clicks a button on Computer 2, what I'm trying to do is use the Remote Controller to start up a second macro on Computer 1. Unfortunately this is resulting in some very strange behaviour. For example, I am no longer able to stop the first macro and the second macro doesn't seem to execute properly.

My basic question is: are you able to run two macros concurrently on the one machine? I'm aware that obviously if they both interact with UI there could be problems but I can use semaphores for this. In my case, there shouldn't really be an issue as one macro is doing file processing and the other is doing GUI work.

I'm aware of the script compiler but I'd prefer to work with interpreted macros at least during development as this is far easier to manage and debug.

Thanks,

Ken

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Oct 05, 2009 10:59 am

Yes. Easier with compiled macros. But if you want to do it with interpreted scripts then ...

First go into Tools/Options and then check the option "Allow Multiple Instances". You will need to restart Macro Scheduler for this to take effect.

Now you can run multiple scripts at the same time via the command line.

E.g. lets say you have the following macro:

Code: Select all

Let>MSG_XPOS=%xpos%
Let>x=0
Repeat>x
  Let>x=x+1
  Wait>0.1
  Message>x
Until>x=100
And lets have a macro that starts two copies of this script:

Code: Select all

Let>path=c:\program files (x86)\Macro Scheduler 11
Run>"%path%\msched.exe" "%SCRIPT_DIR%\xRepeat.scp" /xpos=50
Wait>2
Run>"%path%\msched.exe" "%SCRIPT_DIR%\xRepeat.scp" /xpos=200
That could just as easily be a batch file. But now you will see two separate copies of that script running at the same time in different message windows at different positions.

Could just as easily be two different scripts. The 2 second delay is just to make it obvious that they are two copies.

As for stopping them - well here's a dilemma - the stop key sequence (which by default is SHIFT-ESC) is a global system wide hotkey. Only ONE thing can listen to this, so only the first macro (or your existing running copy of Macro Scheduler) will act on it. So you might want to create your own method of stopping the macros if you want them all to stop at once (hint: a FILE_EXISTS OnEvent procedure perhaps).
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

klcmay
Newbie
Posts: 16
Joined: Sun Jun 01, 2008 10:12 pm

Thanks

Post by klcmay » Mon Oct 05, 2009 11:44 am

Thanks for this - very helpful.

My problem was with the way I was starting up the scripts. The long running script was started via the run arrow on the Macro Scheduler GUI. This meant that when the second macro was started (using the msnet remote controller) it seemed to hang/pause.

I have now got this working by changing the way the main script is started (as per your example). I guess the key message is "you can run multiple scripts at the same time via the command line"!

Thanks again,

Ken

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts