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));
}
}
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));
}
}