First I Get notepad's handle
HANDLE hNote = FindWindow(....)
Now Question is
PostMessage(hNote,WM_KEYDOWN,0x31,0x470001);
is success
but
When i use
SendMessage(hNote,WM_KEYDOWN,0x31,0x470001);
it's does not work
i want to know why
thank you
This is a discussion on problem with SendMessage within the Windows Programming forums, part of the Platform Specific Boards category; First I Get notepad's handle HANDLE hNote = FindWindow(....) Now Question is PostMessage(hNote,WM_KEYDOWN,0x31,0x470001); is success but When i use SendMessage(hNote,WM_KEYDOWN,0x31,0x470001); ...
First I Get notepad's handle
HANDLE hNote = FindWindow(....)
Now Question is
PostMessage(hNote,WM_KEYDOWN,0x31,0x470001);
is success
but
When i use
SendMessage(hNote,WM_KEYDOWN,0x31,0x470001);
it's does not work
i want to know why
thank you
Because you are posting your message to a window in a different process... SendMessage wait's for the function to return, it can't know where to return to across isolated processes thus the call fails. PostMessage does not wait for the function to return so it can succeed across the process boundary.
FWIW... if you are sending WM_KEYDOWN... don't forget to also send WM_KEYUP as any subsequent WM_KEYDOWN messages will either be ignored (creating a dead key) or cause errors in the target process.
Last edited by CommonTater; 02-15-2011 at 08:35 AM.