-
Автор темы
- #1
Простой эмуятор стрейфов, не самый лучший, надо бы сделать более плавнее и возврат в начальную точку при отпускании мыши. Но я не умею правильно прерывать лупы
Код:
#include <iostream>
#include <Windows.h>
#define WINVER 0x0500
using namespace std;
int state = 0;
int sens;
char keycode = 0x02;
int key;
int speed;
int main()
{
INPUT ip;
Sleep(500);
ip.type = INPUT_KEYBOARD;
cout << "Mouse move range (10-30):\n ";
cin >> sens;
cout << "Speed (13-20):\n ";
cin >> speed;
cout << "Key (| ALT - 1 | Mouse2 - 2 | V - 3 | MBUTTON - 4|):";
cin >> key;
if (key == 1)
{
keycode = 0x12;
}
else if (key == 2)
{
keycode = 0x2;
}
else if (key == 3)
{
keycode = 0x56;
}
else if (key == 4)
{
keycode = 0x04;
}
cout << "GOOD LUCK!\n";
while (1) {
if (GetAsyncKeyState(keycode) < 0)
{
mouse_event(MOUSEEVENTF_MOVE, sens, 0, 0, 0);
ip.ki.wScan = 0x20; // DirectInput "D" key
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;
// Жмем кнопку
ip.ki.dwFlags = KEYEVENTF_SCANCODE;
SendInput(1, &ip, sizeof(INPUT));
state = 1;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, sens, 0, 0, 0);
state = 2;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, sens, 0, 0, 0);
state = 3;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, sens, 0, 0, 0);
state = 4;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, sens, 0, 0, 0);
state = 5;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, sens, 0, 0, 0);
state = 6;
// Отпускаем D
ip.ki.dwFlags = KEYEVENTF_KEYUP | KEYEVENTF_SCANCODE;
SendInput(1, &ip, sizeof(INPUT));
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, -sens, 0, 0, 0);
ip.ki.wScan = 0x1E; // DirectInput "A" key
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;
// Жмем
ip.ki.dwFlags = KEYEVENTF_SCANCODE;
SendInput(1, &ip, sizeof(INPUT));
state = 7;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, -sens, 0, 0, 0);
state = 8;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, -sens, 0, 0, 0);
state = 9;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, -sens, 0, 0, 0);
state = 10;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, -sens, 0, 0, 0);
state = 11;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, -sens, 0, 0, 0);
state = 12;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, -sens, 0, 0, 0);
state = 13;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, -sens, 0, 0, 0);
state = 14;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, -sens, 0, 0, 0);
state = 13;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, -sens, 0, 0, 0);
state = 16;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, -sens, 0, 0, 0);
state = 17;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, -sens, 0, 0, 0);
state = 18;
// Отпускаем
ip.ki.dwFlags = KEYEVENTF_KEYUP | KEYEVENTF_SCANCODE;
SendInput(1, &ip, sizeof(INPUT));
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, sens, 0, 0, 0);
ip.ki.wScan = 0x20; // DirectInput "D" key
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;
// Жмем
ip.ki.dwFlags = KEYEVENTF_SCANCODE;
SendInput(1, &ip, sizeof(INPUT));
state = 19;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, sens, 0, 0, 0);
state = 20;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, sens, 0, 0, 0);
state = 21;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, sens, 0, 0, 0);
state = 22;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, sens, 0, 0, 0);
state = 23;
Sleep(speed);
mouse_event(MOUSEEVENTF_MOVE, sens, 0, 0, 0);
/* Отпускаем "D" */
ip.ki.dwFlags = KEYEVENTF_KEYUP | KEYEVENTF_SCANCODE;
SendInput(1, &ip, sizeof(INPUT));
state = 24;
}
}
}
Пожалуйста, авторизуйтесь для просмотра ссылки.
Пожалуйста, авторизуйтесь для просмотра ссылки.