Send Keys to active window with SendKeys.Send
In the MSDN page related to SendKeys.Send I read:
Quote:
If your application is intended for international use with a variety of keyboards, the use of Send could yield unpredictable results and should be avoided.
VERY WELL... there is only one problem: they don't say what is better to use in their place!
Re: Send Keys to active window with SendKeys.Send
You can either send general keyboard input to the active window or not, i.e. send specific text to a specific window. You can use API functions to determine what is the active top-level window and what is the active child window within that and then send specific text to it. The last function would be SendMessage. Before that, it would likely be something like GetActiveWindow, but it's not something I've done myself so I'm not sure. I'm sure some web searching would yield examples. You might also take a look at www.pinvoke.net for Windows API information.
Re: Send Keys to active window with SendKeys.Send
Ty for the answer.
1) SendKeys.Send ===> non need to get the handle of the active window
2) keybd_event API ===> non need to get the handle of the active window, but it seems obsolete :mad:
3) SendMessage API ===> need to get the handle of the active window by GetActiveWindow, and it's a bit more difficult to send keys combinations
If few words... SendKeys.Send should be the best solution, and I really can't understand why Microsoft does'nt update it.
Re: Send Keys to active window with SendKeys.Send
keybd_event is indeed obsolete, but it has been superseded by SendInput. That may or may not suffer from similar issues to SendKeys.