http://msdn.microsoft.com/en-us/library/ms644950(v=vs.85).aspx
LRESULT WINAPI SendMessage( __in HWND hWnd, __in UINT Msg, __in WPARAM wParam, __in LPARAM lParam );
hWnd is the window handle for sending the message. Msg is the type of message to send. WParam and lParam are essentially "information." The exact use will depend on the message being sent.
What is your situation when you need to use SendMessage instead of SendKeys to emulate keys? I used to use SendMessage, but always was for mouse movements .. SendKeys () should send any keystroke that you specify in the active window.
Public Shared Sub ActivateWin() Dim Win As Process = Process.GetProcessesByName("myWindow").First AppActivate(Win.Id) End Sub
I used this above immediately before SendKeys (), and it always worked.
If this does not work or you want to use SendMessage to use SendMessage; The documentation for the WM_KEYDOWN message is what you need. http://msdn.microsoft.com/en-us/library/ms646280(v=vs.85).aspx
You will manipulate the bits to create the correct lParam value.
source share