16,473
社区成员
发帖
与我相关
我的任务
分享
LPRECT lprect=new RECT();
::GetWindowRect(hVitualGridCtrl,lprect);
int tempy=(int)((lprect->top+lprect->bottom)/2);
int tempx=(int)((lprect->left+lprect->right)/2);
LPPOINT lppoint=new POINT();
::GetCursorPos( lppoint);
strTrace.Format("中心x点坐标%d,中心y点坐标%d,鼠标点坐标x%d,鼠标点坐标y %d,x向移动%d,y向移动%d",tempx,tempy,lppo int->x,lppoint->y,tempx-(lppoint->x),tempy-(lppoint->y));
cout << (LPCTSTR)strTrace;
mouse_event(MOUSEEVENTF_MOVE,tempx-(lppoint->x),tempy-(lppoint->y),0,0);
mouse_event(MOUSEEVENTF_MOVE|ABSOLUTE,tempx,tempy,0,0);
BOOL NSys::InputMouseMove(int x, int y, int z, BOOL bScreenPos)
{
INPUT input;
BOOL bRetVal;
int nScrW, nScrH;
nScrW = GetSystemMetrics(SM_CXSCREEN);
nScrH = GetSystemMetrics(SM_CYSCREEN);
x = (x)*(65536-1)/(nScrW-1);
y = (y)*(65536-1)/(nScrH-1);
input.type = INPUT_MOUSE;
input.mi.dwExtraInfo = NULL;
input.mi.dx = x;
input.mi.dy = y;
input.mi.mouseData = z;
input.mi.time = 0;
if(bScreenPos)
input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE;
else
input.mi.dwFlags = MOUSEEVENTF_MOVE;
if(z != 0)
input.mi.dwFlags |= MOUSEEVENTF_WHEEL;
else
input.mi.dwFlags |= MOUSEEVENTF_MOVE;
bRetVal = SendInput(1, &input, sizeof(input));
return bRetVal;
}
LPRECT lprect=new RECT();
::GetWindowRect(hVitualGridCtrl,lprect);
为什么不是
RECT rc = { 0 };
::GetWindowRect(hVitualGridCtrl, &rc);
为什么要new一个
下面的POINT同理
2.
你不说说的显示器的状态么
void CCheckCursorDlg::OnButton3()
{
// TODO: Add your control notification handler code here
CRect wrc;
GetWindowRect(wrc);
CPoint ptc=wrc.CenterPoint();
// SetCursorPos(ptc.x,ptc.y); //比较这句
int mx = ptc.x * 65535 / GetSystemMetrics(SM_CXSCREEN);
int my = ptc.y * 65535 / GetSystemMetrics(SM_CYSCREEN);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, mx, my, 0, 0);
}
// SetCursorPos(ptc.x,ptc.y); //比较这句
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 0, 0, 0, 0);
Sleep(1000);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 65535 / 2, 0, 0, 0);
Sleep(1000);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 65535 , 0, 0, 0);
Sleep(1000);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 65535, 65535/2, 0, 0);
Sleep(1000);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 65535 , 65535, 0, 0);
Sleep(1000);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 65535 /2, 65535, 0, 0);
Sleep(1000);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 0, 65535, 0, 0);
Sleep(1000);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 0 , 65535/2, 0, 0);
Sleep(1000);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 65535 /2, 65535/2, 0, 0);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 0, 0, 0, 0);
Sleep(1000);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 65535 / 2, 0, 0, 0);
Sleep(1000);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 65535 , 0, 0, 0);
Sleep(1000);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 65535, 65535/2, 0, 0);
Sleep(1000);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 65535 , 65535, 0, 0);
Sleep(1000);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 65535 /2, 65535, 0, 0);
Sleep(1000);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 0, 65535, 0, 0);
Sleep(1000);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 0 , 65535/2, 0, 0);
Sleep(1000);
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 65535 /2, 65535/2, 0, 0);