Visual Basic Development Bookmark and Share   
 Home > Visual Basic General > SendKeys underlying API or API equivalent to SendKeys?
 

SendKeys underlying API or API equivalent to SendKeys?

I'm pretty sure this isn't the right forum but I don't know what would be the right forum for this.

I'm looking for the underlying Win32 API call that the DotNET Framework invokes on a SendKeys.Send or .SendWait call, or a Win32 API Equivalent to SendKeys. I've already experimented with SetKeyboardState which seems like the way to go, except that it does not raise any kind of keyboard event that causes the set keystates to register with an active application or the OS (at least not until another key is pressed; for example I can meddle with the keyboardstate before events process on a natural keystroke, but I can't invoke a keystroke programmatically).
It never hurts to try. In a worst case scenario, you'll learn from it.
Andrew B. Painter  12 hours 6 minutes ago
Looking at the code in reflector - it appears that SendKeys first tests to see if it can install a keyboard hook in the other process - if it can then it basically clears the keyboard state, sets the hook, and then calls SetKeyboardState. If it can't establish a hook - then it uses SendInput, though I notice it doesn't call AttachThreadInput first. I have found that SendInput is not very reliable without a call to AttachThreadInput....

Anyway, if your going to replicate SendKeys, your pretty much doomed to the second method - using SendInput, because you can't establish a cross process hook in managed code (the run time is calling an unmanaged dll for the hook proc).

check here for an example:

http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/41d58def-87cb-41e5-93a4-2ad7d1fb7e0b

Tom Shelton
Tom Shelton  11 hours 54 minutes ago
Looking at the code in reflector - it appears that SendKeys first tests to see if it can install a keyboard hook in the other process - if it can then it basically clears the keyboard state, sets the hook, and then calls SetKeyboardState. If it can't establish a hook - then it uses SendInput, though I notice it doesn't call AttachThreadInput first. I have found that SendInput is not very reliable without a call to AttachThreadInput....

Anyway, if your going to replicate SendKeys, your pretty much doomed to the second method - using SendInput, because you can't establish a cross process hook in managed code (the run time is calling an unmanaged dll for the hook proc).

check here for an example:

http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/41d58def-87cb-41e5-93a4-2ad7d1fb7e0b

Tom Shelton
Tom Shelton  11 hours 54 minutes ago

You can use google to search for other answers

Custom Search

More Threads

• Changing IP issue
• Asynchronous Sockets...
• Walkthrough -- Select XML File... click Add but there is no XML File Choice
• Media Player Issues
• Contending with New Versions of VS/Windows
• VB.net Sort Dataset or Bind DataSet to Dataview
• Problems installing VB6 program onto other computers...
• Can't debug or run my first program very basic
• populate a drop down list for a SP with a paremeter
• connection string and back ground worker