Jump to content
Macro Express Forums

AutoIt with ME3


rberq
 Share

Recommended Posts

I'm working with AutoIt for the first time ever, and have a problem which is no doubt self-inflicted.

 

ME macro 1 launches autoit3 with parameters to run an au3 script which is simply

BlockInput(1)

Sleep(30000)

BlockInput(0)

This does as I expected, locks the keyboard and mouse for 30 seconds, then releases them.

 

ME macro 2 launches an au3 script which is

BlockInput(0)

 

I scheduled macro 2 to run every three seconds. What I expected to see was, when I run macro 1,

the mouse and keyboard would stay locked for only a few seconds. But the second macro and

script has no effect -- the input stays locked for the full 30 seconds.

 

Howcum? Microsoft documentation for BlockInput mentions that a block must be cleared by the

same thread that established the block. Is that what the problem is -- the second macro and script

are a different thread? What can be done about it?

Link to comment
Share on other sites

Edit: misunderstood the question

 

Could you run the BlockInput(0) before ME macro 2?

 

 

although i do not know why you block input for 30 seconds, i assume the macro is running code, you could just block the input for the duration of the code running then run macro two.

 

BlockInput(1)

(Do code)

BlockInput(0)

Link to comment
Share on other sites

Sorry, I think I should have explained in more detail.

 

I wanted to test whether one macro could block input (via autoit), and a second macro could unblock it. Both of the macros consist of a single line, launching an au3 script.

 

Macro 1 launches the blocking au3 script and then the macro ends immediately. The 30-second delay is in the au3 script, not in the macro.

Macro 2 launches the unblocking au3 script and then the macro ends immediately (and runs again and again, every 3 seconds).

 

I can see from the ME log file that Macro 1 runs when I start it.

I can see from the ME log file that Macro 2 runs multiple times before, during, and after the 30 seconds that the blocking au3 script is running.

But the input block does not clear until the original blocking script finishes.

 

Therefore, it seems that when one au3 script has blocked input, another au3 script can not unblock it; only the original au3 script can release its own block. Is this your understanding of how AutoIt works?

Link to comment
Share on other sites

Here's the answer!

I wrote Test1.au3:

BlockInput(1)
Sleep(20000)
BlockInput(0)  -- actually irrelevant since BlockInput is cleared automatically when Test1 ends

and Test2.au3

BlockInput(0)

And my macro (in MEP, but no matter):

Program Launch "Test1.exe"
Delay 3
Program Launch "Test2.exe"

And, just as you experienced, running test2 made no difference.

 

Now change Test2 as follows:

BlockInput(1)
  BlockInput(0)

and you'll see that Test2 now achieves what you expected in the first place.

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...
 Share

×
×
  • Create New...