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- Marked As Answer byAndrew B. Painter 11 hours 37 minutes ago
-
|