想写一个模拟后台点击工具栏按钮的东西所遇到的问题
如题我本来是想用发送消息sendmessage实现的,可是
1. wm_command消息,我对着那个窗口点击了 工具栏的按钮 可是spy++截取不到command消息
2. ::SendMessage(hwnd,WM_PARENTNOTIFY,WM_LBUTTONDOWN,(LPARAM)MAKELONG(496,22)); 工具栏按钮刚好位于那个位置,一点反应也没有.
程序代码:HDC dc = ::GetDC(NULL);
CDC *pDc = CDC::FromHandle(dc);
CRect rect;
::GetWindowRect(hwnd,rect);
pt.x += rect.left;
pt.y += rect.top;
COLORREF colorref;
CString str;
CString strTmp;
for (int i=0; i<nCount; i++)
{
colorref = pDc->GetPixel(pt);
if (colorref != 3394100)
return FALSE;
str.Format("%d R:%d\tG:%d\tB:%d\tCOLORREF:%d\nxPos:%d\tyPos:%d\n",i+1
,GetRValue(colorref),GetGValue(colorref),GetBValue(colorref),colorref,
pt.x,pt.y);
strTmp +=str;
// AfxMessageBox(str); //只要取消注释主句,循环语句 从第二次开始 GetPixel就返回-1
pt.y += 17;
Sleep(10);
}
// AfxMessageBox(strTmp);
pDc->DeleteDC();
return TRUE;