Sign in to follow this  
Followers 0
Toady

Send() Key down stays after scipt exit

8 posts in this topic

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?


www.itoady.com

A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Sure enough, all it takes to demo is a one line script:

Send("{SHIFTDOWN}")

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.

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Sure enough, all it takes to demo is a one line script:

Send("{SHIFTDOWN}")

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 :D

www.itoady.com

A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding

Share this post


Link to post
Share on other sites

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

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 :)


www.itoady.com

A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding

Share this post


Link to post
Share on other sites

I have found a solution to this though. Thanks for all of your input

Please enlight us.. so the next to ask the question would be able to find the answer here :)


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

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.


www.itoady.com

A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding

Share this post


Link to post
Share on other sites

Just have a array keeps hold of all keys that have been down and remove them on the up... so if theres any keys left in the array its because it hasn't been raised :)


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0