findwindow 后postmessage点解按钮

        HWND    hWnd1,hWnd2;  

        hWnd1 = ::FindWindow(NULL,_T("Dlg"));
        if(hWnd1)  
        {

                hWnd2 = ::FindWindowEx(hWnd1,NULL,_T("Button"),"&Yes");
                if(!hWnd2) 
                hWnd2 = ::FindWindowEx(hWnd1,NULL,_T("Button"),"是(&Y)");

            
            if(hWnd2)
            {  
                ::PostMessage(hWnd2,WM_LBUTTONDOWN,MK_LBUTTON,MAKELPARAM(0,0));
                ::PostMessage(hWnd2,WM_LBUTTONUP,MK_LBUTTON,MAKELPARAM(0,0));  

                 ::PostMessage(hWnd2,WM_LBUTTONDOWN,MK_LBUTTON,MAKELPARAM(0,0));        
                 ::PostMessage(hWnd2,WM_LBUTTONUP,MK_LBUTTON,MAKELPARAM(0,0));
            }
        }  
posted @ 2012-02-03 17:47  ahuo  阅读(598)  评论(1编辑  收藏  举报