/////////////////////////////////////线程函数; CMainFrame::CMainFrame() { HWND hWnd=::GetParent(NULL); GetCursorPos(&mp); AfxBeginThread(FMouse,hWnd,0); //启动模拟鼠标行为的线程; } UINT FMouse(LPVOID param) { WINDOWPLACEMENT wp;///窗口位置 wp.length=sizeof(WINDOWPLACEMENT); HWND hWnd; char tmp[20]; RECT rt; int iResult; iResult=AfxMessageBox("确实要隐藏吗?",MB_OKCANCEL); if(iResult==IDOK) { while(1) { hWnd=GetForegroundWindow();//得到系统中最前端窗口的句柄; GetWindowRect(hWnd,&rt); GetWindowText(hWnd,tmp,20); GetWindowPlacement(hWnd,&wp);//得到当前窗口的位置; GetCursorPos(&cursorNew);//得到当前鼠标的位置; while(1){ ::mouse_event(MOUSEEVENTF_MOVE,cursorNew.x,cursorNew.y,0,0); //模拟鼠标的移动; } } } return 0;//结束线程; }
|