Jump to content
Macro Express Forums

Multithreading / Simultaneous Macros Or Loops?


Jomdom

Recommended Posts

I am currently writing a macro for a program that is fairly buggy. It crashes occasionally, and therefore I want to be able to poll the status of the program every 10 seconds or so as my macro is running.

 

The only way I can figure out how to do this is to actually inject the logic right into the macro itself, thus causing horrible duplication and a cluttered scripting/direct editor.

 

So my question is this: is there any way to repeatedly loop through X lines of logic every Y seconds while another macro is running?

 

Thanks in advance!

Link to comment
Share on other sites

Okay, so here's a long shot... Would it be possible to run two instances of ME, with program status being polled via a scheduled macro every 1 minute in one instance, with the other macro running in the other instance? I realize there would be serious conflicts if both tried to take control of keyboard or mouse, but what about simple status checking & variable setting/clearing?

Link to comment
Share on other sites

This might work under XP if you launch two instances as two different users, switching between them. You would not, however, have access to the other's memory space, so you will not be able to check variables. Instead, write the variables to a CSV file and have the other instance check them.

 

Timing in this scenario is everything so use the Wait for File Exist and Wait for File Ready commands.

Link to comment
Share on other sites

This might work under XP if you launch two instances as two different users, switching between them.
This will work if you have 'Fast User Switching' enabled in Windows XP.

 

Another thing to consider would be to create a separate macro that performs the 'monitoring' function you desire. Then in the main macro put Macro Run commands to 'call' the monitoring macro at strategic locations. This wouldn't cause too much clutter. You could even set a variable at the top of the main macro and check that variable within the called macro to turn off the monitoring.

Link to comment
Share on other sites

  • 1 year later...

In order to do this you need to make sure that Windows XP has 'Fast User Switching' enabled and that you have more than one user login. When you log on as one user Macro Express gets loaded for that user. When you 'switch' to another user, that user login has Macro Express running. Both are running at the same time.

 

There are limitations, however. When you switch from one user to another, a macro will continue to run for the user that is logged in but is not active. But Windows will not send keystrokes and mouse events to a program that does not have focus so the macro may appear to stop functioning.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...