模拟鼠标移动的函数是:SetCursorPos(x,y); 移动至(x,y)处
模拟鼠标点击的函数是:mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); 鼠标左键按下
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); 鼠标左键弹起
以下这段代码是模拟鼠标的操作来实现家园守卫战的自动作战任务,有点类似于外挂。
// homeProtect.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "homeProtect.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/
// The one and only application object
CWinApp theApp;
int nCount=0;
#define NUM 4 //打击海盗的次数
#define X_POS 835
#define Y_POS 535
#define PAN_X X_POS
#define PAN_Y Y_POS
#define SHOW_X 637
#define SHOW_Y 174
using namespace std;
void mouse_moveto(int x,int y)//移动鼠标到指定位置
{