Hide your mouse

Source: Internet
Author: User

(Note: This code has a certain risk, such as you can not control your computer, please log off or restart)

First, build a single document application framework

Second, to hide the main window, will be oncreate deleted.

and modify the m_pMainWnd in the app class to point to ShowWindow (Sw_hide)

Three, now in the mainframe implementation file add the following content: Point Mp,cursornew;
/////////////////////////////////////
//CMainFrame construction/destruction
UINT fmouse (LPVOID param)   
{
int flag=0;
  Windowplacement wp;///window Position
wp.length=sizeof (windowplacement);
HWND hwnd;
Char tmp[20];
RECT RT;
Hwnd=getdesktopwindow ();////getforegroundwindow ();
GetWindowPlacement (HWND,&WP);
GetWindowRect (HWND,&RT);
GetWindowText (hwnd,tmp,20);
HDC dc=getdc (HWND) param);
int iresult;
Iresult=afxmessagebox (Are you sure you want to hide it?). ", Mb_okcancel);       
if (Iresult==idok)
{
while (1)
{
Hwnd=getforegroundwindow ();//getdesktopwindow ();
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;
}

To start a thread in a constructorCMainFrame::CMainFrame()
{
  HWND hWnd=::GetParent(NULL);
  GetCursorPos(&mp);
  AfxBeginThread(FMouse,hWnd,0);
}

OK try it, log off for a while it's OK!

This article supporting source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.