Hello all,
I'm writing a C# WinForms application that monitors a button of another application (non .net), and if the button in the other application is clicked, the listening app runs some sort of routine.
I have already found the handle of the button using spy++ and the FindWindow() and FindWindowEx() API calls. When the button of the other app is clicked, it generates messages such as WM_LBUTTONDOWN indicating the left mouse button was clicked on that button.
Also, would a timer be the best way to watch these messages I like the way overwriding the WndProc event of the form works that intercepts all the messages without needing a timer, but unfortunately that only works in the current form that is .net managed, and this is for watching a completely seperate app that was not built with .net.
To further explain, I would be looking for something similar to the following:
private void timer1_Tick(object sender, EventArgs e){
int hwnd = FindButtonHandle();
if(MessageEvent(hwnd) == WM_LBUTTONDOWN)
MessageBox.Show("The button in the other app was clicked");
}
But it doubt whether this is the best method, as a timer would likely miss the WM_LBUTTONDOWN message if it is not checking fast enough. I have heard about setting a hook to the button, can anyone give me a sample of how this work
Any help would be greatly appreciated, as I have been trying to find an answer for this for a while!

Listening to button click messages of another application