jeudi 26 juin 2014

How to find another program's MessageBox by WindowsAPI in C#?


Vote count:

0




my problem : i'm trying to find another program's(made by mfc) MessageBox using FindWindow, FindWindowEx in WindowsAPI. But, i'm fall in infinite loop. 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

/******** here is Problem Code. (infinite loop) ********/
//int main = FindWindow(null, "Create Connecter"); // Parent
//main = FindWindowEx(main, 0, null, "Encode"); // MessageBox
// i'm tried to this code.. but, failed.

int main = FindWindow(null, "Encode"); // MessageBox
int finish = 0;
do {
finish = FindWindowEx(main, 0, null, "Encode");
textBox1.AppendText("Wating....");
System.Threading.Thread.Sleep(100);
} while (finish == 0);
textBox1.AppendText("Find MessageBox !!");
/********************************************************/

// OK Button Click in MessageBox
finish = FindWindowEx(finish, 0, "Button", "OK");
SendMessage(hWnd, WM.LBUTTONDOWN, 0, null);
SendMessage(hWnd, WM.LBUTTONUP, 0, null);


so.. 1. target Program's Create Button Click -> appeared MessageBox in target Program 2. i'm trying to find target program's MessageBox 3. i'm fall in infinite loop


somebody help me.. i want go to bed..



asked 31 secs ago






Aucun commentaire:

Enregistrer un commentaire