Reading keyboard within a sub
Is there any way to read the keyboard WITHIN a sub that I create? I really only want to see if somone pushes the "a" or "A" key to abort a lengthy operation. I am trying to avoid DO EVENTS at all cost. I just rewrote a bunch of code to remove doevents after it almost gave me an ulcer---all works great now., but I lost the abort ability.
Just wondering if reading the keyboard with a function or call is even possible.
I suppose I could dice up the lenghty operation into multiple calls of my sub using statics & thus allow a click event to "jump in between calls" to effect an abort.
Re: Reading keyboard within a sub
If you want to use the click event as interrupter - you can't do away with DoEvents. You may also try the Timer events if it will work on your needs.
Re: Reading keyboard within a sub
GetAsyncKeyState API
Good Luck
Re: Reading keyboard within a sub
Is is really impossible to read or look for a key within your own created routine? Seems like there should be a simple api call so you can: A=abort, D=decrease amount, I=increase amount, etc within your own loop.
any ideas?
Re: Reading keyboard within a sub
From vb to vb, candies did you see my post #3???
If you had, you would not have asked your retorical question in post #4...
Re: Reading keyboard within a sub
Removing DoEvents may speed the app up on your system at the time, but it may lock up some other system that is doing different things (like playing music)
Re: Reading keyboard within a sub
Ähmmm... did somebody mention the KeyPress() event?
You set the focus to the element where you expect key input and the KeyPress() event will be easy to analyze what key has been pressed.
Re: Reading keyboard within a sub
Quote:
Originally Posted by
WoF
Ähmmm... did somebody mention the KeyPress() event?
You set the focus to the element where you expect key input and the KeyPress() event will be easy to analyze what key has been pressed.
Ahhh....
OP said in own sub/function which is looping and without the doevents....
Re: Reading keyboard within a sub
Ahhh... right. Missed that.