Send() Key down stays after scipt exit

8 posts in this topic

Toady 2

One of my scripts sometimes will send a key press down. This state will stay like this even when script exits. Is there are way to "reset" the keyboards status without having to send the key press up? Any methods in user32.dll that does this?

I have searched around and can't find anything about resetting a keyboards key status. I do not want to have to loop through all the keys and if a key is pressed then send the key up. Is this possible?

Share this post

Link to post

Share on other sites

PsaltyDS 25

You could use an AutoItOnExit function to clear whatever your script is leaving behind. I don't know if you really want a "keyboard reset", if such exists, because you would lose things like Num Lock setting, which could be annoying to the user.

Share this post

Link to post

Share on other sites

Toady 2

You could use an AutoItOnExit function to clear whatever your script is leaving behind. I don't know if you really want a "keyboard reset", if such exists, because you would lose things like Num Lock setting, which could be annoying to the user.

Ya good point. As of right now Im just looping through all the possible keys and if a key is pressed it will send the key up for that key. I have this in the AutoItonExit, as well as some other places that will need it. Im trying to keep away from having to loop though all keys becuase my script requires good performance. Thank you for you input

Share this post

Link to post

Share on other sites

SkinnyWhiteGuy 2

Well, just from reading the post, wouldn't it be almost as easy to, when you send the Down Key within your script, record it to an array, and when you do your checking, instead of checking all keys, just check the keys in that array list, clear it, and keep going? That would help lessen the size your loop had to go through.

Share this post

Link to post

Share on other sites

Toady 2

Well, just from reading the post, wouldn't it be almost as easy to, when you send the Down Key within your script, record it to an array, and when you do your checking, instead of checking all keys, just check the keys in that array list, clear it, and keep going? That would help lessen the size your loop had to go through.

I had that idea but I didn't want to any comparing in real-time during one of my function calls, performance is crucial. I have found a solution to this though. Thanks for all of your input

Share this post

Link to post

Share on other sites

Toady 2

My script requires that user to create a macro of keystrokes, sometimes the user can forget to add a key up after a key down. This would make the key never get released until he/she has pressed that key again manually.

So instead I made a function to check the entire list of keystrokes the user has entered and if a key hold does not have a key up then a message is displayed warning them about it and how to fix it.