有什么可以代替mouse_event

可以在屏幕任意坐标位置单击.............

你是看了msdn的说明了,可是我是专门为这个写了一个测试程序的哦。

你可以试一试,把鼠标放在CMouse_event_DialogTextDlg窗口的标题栏处,按下pagedown键,在2000下鼠标会自动拖着窗口往下拉,而在98下就不行了。

代码如下:
BOOL CMouse_event_DialogTextDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
POINT pt ;
switch(pMsg->wParam)
{
case VK_NEXT:
::GetCursorPos(&pt);

POINT scaled ;
scaled.x = (pt.x * 65535) / (GetSystemMetrics(SM_CXSCREEN)-1);
scaled.y = (pt.y * 65535) / (GetSystemMetrics(SM_CYSCREEN)-1);
::mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN, scaled.x, scaled.y, 0, 0) ;
::SetTimer(GetSafeHwnd(), 1, 2000, NULL) ;
::SetTimer(GetSafeHwnd(), 2, 300, NULL) ;
break ;
}
return CDialog::PreTranslateMessage(pMsg);
}

void CMouse_event_DialogTextDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if (nIDEvent == 1)
{
::KillTimer(GetSafeHwnd(), 1);
::KillTimer(GetSafeHwnd(), 2);
POINT pt ;
::GetCursorPos(&pt);

POINT scaled ;
scaled.x = (pt.x * 65535) / (GetSystemMetrics(SM_CXSCREEN)-1);
scaled.y = (pt.y * 65535) / (GetSystemMetrics(SM_CYSCREEN)-1);

::mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTUP, scaled.x, scaled.y, 0, 0) ;
}
else if (nIDEvent == 2)
{
POINT pt ;
::GetCursorPos(&pt);
pt.x += 10;
pt.y += 10;

POINT scaled ;

scaled.x = (pt.x * 65535) / (GetSystemMetrics(SM_CXSCREEN)-1);
scaled.y = (pt.y * 65535) / (GetSystemMetrics(SM_CYSCREEN)-1);
::mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, scaled.x, scaled.y, 0, 0) ;
}
CDialog::OnTimer(nIDEvent);
}
温馨提示:答案为网友推荐,仅供参考