Hello, I have been searching for a working example on how to accomplish this, but no luck so far.
This is what I have right now :
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr
wParam, IntPtr lParam);
Process[] processlist = Process.GetProcesses();
foreach (Process p in processlist)
{
if (p.ProcessName == "notepad")
{
//MessageBox.Show("bu");
/*
LRESULT PostMessage( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
WM_KEYDOWN
WPARAM wParam
LPARAM lParam;
Parameters
wParam
Specifies the virtual-key code of the nonsystem key.
lParam
Specifies the repeat count, scan code, extended-key flag,
context code, previous key-state flag, and transition-state flag,
as shown in this table.
......So......
LRESULT debugvalue = PostMessage( Handle_to_where_the_message_is_going,
WM_KEYDOWN, (WPARAM)VK_ENTER, (LPARAM)0)
*/
uint WM_KEYDOWN = 0x0100;
PostMessage(p.Handle, WM_KEYDOWN, Marshal.StringToHGlobalAuto("something"), IntPtr.Zero);
}
}
Now, what am I doing wrong?
http://msdn.microsoft.com/en-us/library/ms646280%28VS.85%29.aspx May be of assistance