// jared bruni #include LRESULT APIENTRY WndProc(HWND,UINT,WPARAM,LPARAM); void init(); void update(); void closeMail(); // will HWND getmailwindow(); bool closemail = false; HWND hwnd; HINSTANCE hInst; int APIENTRY WinMain(HINSTANCE hInstx,HINSTANCE hPrev,LPSTR line,int CmdShow) { hInst = hInstx; init(); MSG msg; while(GetMessage(&msg,0,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); update(); } return 0; } void init() { WNDCLASS wc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH); wc.hInstance = hInst; wc.hIcon = LoadIcon(NULL,IDI_APPLICATION); wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hInstance = hInst; wc.lpfnWndProc = (WNDPROC) WndProc; wc.lpszClassName = "Master"; wc.lpszMenuName = NULL; wc.style = CS_HREDRAW | CS_VREDRAW; RegisterClass(&wc); hwnd = CreateWindowEx(WS_EX_STATICEDGE,"Master","Example for Inc",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,640,480,0,0,hInst,0); ShowWindow(hwnd,SW_SHOW); UpdateWindow(hwnd); } LRESULT APIENTRY WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) { switch(msg) { case WM_DESTROY: PostQuitMessage(0); break; case WM_LBUTTONDOWN:// trigger for closeMail { closeMail(); } break; default: return DefWindowProc(hwnd,msg,wParam,lParam); } return 0; } void closeMail() { HWND mail; mail = getmailwindow(); if(mail) { closemail = true; SendMessage(hwnd,WM_SETTEXT,255,(LPARAM)(LPCSTR)"Mail Window Closed.. Waiting for it to Appear"); SendMessage(mail,WM_CLOSE,0,0); } else { MessageBox(0,"No Mail Window Found",0,MB_OK); } } void update() { if(closemail == true) { if(getmailwindow()) { SendMessage(hwnd,WM_SETTEXT,255,(LPARAM)(LPCSTR)"Mail Window Open...."); closemail = false; SendMessage(getmailwindow(),WM_SETTEXT,255,(LPARAM)(LPCSTR)" This Mail Window, was waited for"); MessageBox(0,"Mail Window has been opened, and while you waited, there was no lag",0,0); } } } HWND getmailwindow() { HWND aol; aol = FindWindow("AOL Frame25",NULL); HWND mdi; mdi = FindWindowEx(aol,0,"MDIClient",0); HWND mail; mail = FindWindowEx(mdi,0,"AOL Child","Write Mail"); return mail; }