外挂开发 硬件级模拟键盘鼠标

INPUT   MouseInput[2];
MouseInput[0].type = INPUT_MOUSE;//虚拟的类型 INPUT_MOUSE or INPUT_KEY
MouseInput[0].mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE; //鼠标标志 MOUSEEVENTF_LEFTDOWN  MOUSEEVENTF_ABSOLUTE
MouseInput[0].mi.dx = (65535 / (GetSystemMetrics(SM_CXSCREEN) - 1))* 150;//鼠标x坐标
MouseInput[0].mi.dy = (65535 / (GetSystemMetrics(SM_CYSCREEN) - 1))* 150;//鼠标y坐标
Sleep(50);
if (SendInput(1, MouseInput, sizeof(INPUT)) == 0)
{
	MessageBox("INPUT被占用","错误");
}
INPUT KeyInput[4];
memset(KeyInput, 0, sizeof(KeyInput));
//设置模拟键盘输入
KeyInput[0].type = INPUT_KEYBOARD;
KeyInput[1].type = INPUT_KEYBOARD;
KeyInput[2].type = INPUT_KEYBOARD;
KeyInput[3].type = INPUT_KEYBOARD;
KeyInput[0].ki.wVk =VK_MENU;
KeyInput[1].ki.wVk = VK_F4;
KeyInput[2].ki.wVk = VK_MENU;
KeyInput[3].ki.wVk = VK_F4;
// 弹起按键
KeyInput[2].ki.dwFlags = KEYEVENTF_KEYUP;
KeyInput[3].ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(4, KeyInput, sizeof(INPUT));//把消息发送到消息队列

 

你可能感兴趣的:(外挂开发 硬件级模拟键盘鼠标)