Send Click Message to another application process
Posted
by
Nazar Hussain
on Stack Overflow
See other posts from Stack Overflow
or by Nazar Hussain
Published on 2010-12-23T11:38:34Z
Indexed on
2012/10/02
21:37 UTC
Read the original article
Hit count: 222
I have a scenario, i need to send click events to an independent application. I started that application with the following code.
private Process app;
app = new Process();
app.StartInfo.FileName = app_path;
app.StartInfo.WorkingDirectory = dir_path;
app.Start();
Now i want to send Mouse click message to that applicaiton, I have specific coordinates in relative to application window. How can i do it using Windows Messaging or any other technique.
I used
[DllImport("user32.dll")]
private static extern void mouse_event(UInt32 dwFlags, UInt32 dx, UInt32 dy, UInt32 dwData, IntPtr dwExtraInfo);
It works well but cause the pointer to move as well. So not fit for my need.
Then i use.
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
It works well for minimize maximize, but do not work for mouse events.
The codes for mousevents i am using are,
WM_LBUTTONDOWN = 0x201, //Left mousebutton down
WM_LBUTTONUP = 0x202, //Left mousebutton up
WM_LBUTTONDBLCLK = 0x203, //Left mousebutton doubleclick
WM_RBUTTONDOWN = 0x204, //Right mousebutton down
WM_RBUTTONUP = 0x205, //Right mousebutton up
WM_RBUTTONDBLCLK = 0x206, //Right mousebutton do
Thanks for the help in advance, and waiting for feedback.
© Stack Overflow or respective owner