Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sendkeys and Numlock

Status
Not open for further replies.

ormsk

Programmer
Sep 30, 2002
147
GB
I have an app where I use the Sendkeys command, but for some reason the numlock is turned off during processing with the True argument.

Anybody know why this is?

I have tried to reset the Numlock again using Sendkeys, but nothing happens.

Thanks in advance
 
Hi Ormsk

I copied this from:


Send all the characters in a single SendKeys statement. -or-

Execute a DoEvents function between each SendKeys statement. However, depending on the complexity of the key strokes, this may not work in all cases. -or-

Determine the setting of the NumLock key prior to using SendKeys. Then, turn off the NumLock before using SendKeys. After using SendKeys, reset the NumLock to its previous setting. This is accomplished using the GetKeyboardState, keybd_event and SetKeyboardState API functions. See the REFERENCES section below for more information. -or-


Use API functions instead of SendKeys. See the REFERENCES section below for more information
 
Check out the code at:

It's a replacement function that allows you to do the same thing as sendKeys, but without the bugs. A very nice solution, which I use to do some critical stuff.

On the other hand, in general it is far better to come up with other ways of doing things than using SendKeys, whether the Access native function or this one. The reason is that when you use SendKeys you rely on the environment being exactly the same as it was when you wrote the code. If you're using this to make changes to data and the menus change, or the user does something while the code is executing, or any number or other thigs go wrong, you could easily find yourself up a stinky creek, looking for a paddle.

If you let us know what you want to use SendKeys for, there's a good chance we'll come up with an alternate solution.

Jeremy =============
Jeremy Wallace
AlphaBet City Dataworks

Take a look at the Developers' section of the site for some helpful fundamentals.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top