rberq Posted November 19, 2009 Report Share Posted November 19, 2009 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? Quote Link to comment Share on other sites More sharing options...
paul Posted November 19, 2009 Report Share Posted November 19, 2009 Me3 allows only one macro to run at a time. Therefore Macro1, which takes 30 seconds to run, prevents macro2 from running until it has ended. MEP does not have this limitation. Quote Link to comment Share on other sites More sharing options...
monpasdg Posted November 19, 2009 Report Share Posted November 19, 2009 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) Quote Link to comment Share on other sites More sharing options...
rberq Posted November 19, 2009 Author Report Share Posted November 19, 2009 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? Quote Link to comment Share on other sites More sharing options...
paul Posted November 19, 2009 Report Share Posted November 19, 2009 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. Quote Link to comment Share on other sites More sharing options...
rberq Posted November 19, 2009 Author Report Share Posted November 19, 2009 Bummer. Doesn't work for me! I wonder what's different between your machine and mine. Mine is XP Pro Service Pack 2. Quote Link to comment Share on other sites More sharing options...
paul Posted November 20, 2009 Report Share Posted November 20, 2009 Bummer. Doesn't work for me! I wonder what's different between your machine and mine. Mine is XP Pro Service Pack 2. SP3, and AutoIt v3.3.0.0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.