nicholassolutions Posted July 23, 2007 Share Posted July 23, 2007 This isn't exactly a bug, but it's a really annoying problem I just discovered with using BlockInput() as part of a function called by a hot key. Consider this code:CODEHotKeySet("^!+a", "my_func");While 1 Sleep(100)WEndFunc my_func() BlockInput(1) Sleep(1000) BlockInput(0) ;Send("{ALTUP}{CTRLUP}{SHIFTUP}")EndFuncSo when the user presses CTRL + SHIFT + ALT + A, my_func is called. It momentarily blocks input, then unblocks it. The problem arises (I think) because the function gets called before the user releases the keys (they release they probably during the sleep). After the function is called -- even after the script has been shut down -- it is as if you are still holding down CTRL + SHIFT + ALT. It's extremely annoying and confusing if you don't realize what happened (at first I thought my CTRL key was stuck ). To fix it, you just have to press each of those keys once (to send the signal to release them) . Uncommenting the last line (that tries to automate the release) doesn't seem to help. Any ideas on how to prevent this? Do you notice the same behavior when you run the script? I'm not sure I'd say it's a bug, because on some level AutoIT is doing exactly what it's supposed to...On the other hand, it can make your programs have bugs when you're doing pretty much what you're supposed to Link to comment Share on other sites More sharing options...
qazwsx Posted July 23, 2007 Share Posted July 23, 2007 You could is If not _ispressed HotKeySet("^!+a", "my_func"); $var = 0 While 1 Sleep(100) WEnd Func my_func() While $var = 0 If Not _ispressed ("watever alt is") and _ispressed etc Then $var = 1 Endif Wend BlockInput(1) Sleep(1000) BlockInput(0) ;Send("{ALTUP}{CTRLUP}{SHIFTUP}") EndFunc Link to comment Share on other sites More sharing options...
Busti Posted July 23, 2007 Share Posted July 23, 2007 Some KEy Combinitions are not Blocked, like CTRL+ALT+DEL My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity Link to comment Share on other sites More sharing options...
nicholassolutions Posted July 23, 2007 Author Share Posted July 23, 2007 That did the trick -- thanks I didn't know about the _IsPressed function Here's my final code in case anyone comes across this later and is interested CODE #Include <Misc.au3> HotKeySet("^!+a", "my_func"); While 1 Sleep(100) WEnd Func my_func() $switch = 1; While $switch If Not (_IsPressed("12") Or _IsPressed("11") Or _IsPressed("10")) Then $switch = 0; EndIf WEnd BlockInput(1) Sleep(1000) BlockInput(0) EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now