I'm trying to find another (MFC) program's MessageBox using FindWindow/FindWindowEx in WindowsAPI. My code is infinite looping. How can I find it?
I'm using this code:
case 17: // target Program's Create Button
// Click
SendMessage(hWnd, WM.LBUTTONDOWN, 0, null);
SendMessage(hWnd, WM.LBUTTONUP, 0, null);
// -> Show MessageBox in Display
// my program is stop. What's the happen ?
/******** here is Problem Code. (infinite loop) ********/
int main = FindWindow(null, "Create Connecter"); // Parent
int finish = 0;
do {
finish = FindWindowEx(main, 0, null, "Encode"); // MessageBox
textBox1.AppendText("Wating....");
System.Threading.Thread.Sleep(100);
} while (finish == 0);
textBox1.AppendText("Find MessageBox !!");
/********************************************************/
// OK Button Click in MessageBox
hWnd = FindWindowEx(finish, 0, "Button", "OK");
SendMessage(hWnd, WM.LBUTTONDOWN, 0, null);
SendMessage(hWnd, WM.LBUTTONUP, 0, null);
That is:
- Target Program's Create Button Click -> appeared MessageBox in target Program
- I'm trying to find target program's MessageBox
- It's infinite looping
- Click on OK Button by my mouse -> continue Next step.
Somebody help me... I want go to bed.