Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // TestSendInputMinecraft.cpp : definisce il punto di ingresso dell'applicazione console.
- //
- #include "stdafx.h"
- #define MOTION_AMOUNT 4
- struct mouseMovement
- {
- int x;
- int y;
- };
- void moveMouse(mouseMovement *movement);
- void doTest();
- int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
- {
- MSG message;
- if (IsDebuggerPresent())
- {
- AllocConsole();
- }
- RegisterHotKey(NULL, 1, MOD_CONTROL | MOD_NOREPEAT, 0x54); // ctrl+t, test
- RegisterHotKey(NULL, 1, MOD_CONTROL | MOD_NOREPEAT, 0x59); // ctrl+y, esci
- memset(&message, 0, sizeof(MSG));
- while (GetMessage(&message, NULL, 0, 0) != 0)
- {
- if (message.message == WM_HOTKEY)
- {
- switch (HIWORD(message.lParam))
- {
- case 0x54: // t
- printf("TEST\n");
- doTest();
- break;
- case 0x59: // y
- return 0;
- break;
- }
- }
- }
- return 1;
- }
- void doTest()
- {
- int i, j;
- mouseMovement directions[4];
- directions[0].x = 1 * MOTION_AMOUNT; // destra
- directions[0].y = 0 * MOTION_AMOUNT;
- directions[1].x = 0 * MOTION_AMOUNT; // basso
- directions[1].y = 1 * MOTION_AMOUNT;
- directions[2].x = -1 * MOTION_AMOUNT; // sinistra
- directions[2].y = 0 * MOTION_AMOUNT;
- directions[3].x = 0 * MOTION_AMOUNT; // alto
- directions[3].y = -1 * MOTION_AMOUNT;
- for (i = 0; i < 4; i++)
- {
- for (j = 0; j < 100; j++)
- {
- moveMouse(&directions[i]);
- Sleep(10);
- }
- }
- return;
- }
- void moveMouse(mouseMovement *movement)
- {
- INPUT input;
- memset(&input, 0, sizeof(INPUT));
- input.type = INPUT_MOUSE;
- input.mi.dwFlags = MOUSEEVENTF_MOVE;
- input.mi.dx = movement->x;
- input.mi.dy = movement->y;
- SendInput(1, &input, sizeof(INPUT));
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement