This code runs fine, but it's because I pass only one mouse event to sendinput? There is a & needed for &input to sendinput()
Here, I passed only one INPUT structure to it, I think that's how it works when there is no array.
Code:
#include <iostream>#include <windows.h>
#include <ctime>
using namespace std;
void main()
{
Sleep(4000);
INPUT input;
input.type = INPUT_MOUSE;
input.mi.dx = 200;
input.mi.dy = 0;
input.mi.mouseData = 0;
input.mi.dwFlags = MOUSEEVENTF_MOVE;
input.mi.time = 0;
input.mi.dwExtraInfo = GetMessageExtraInfo();
SendInput(1, &input, sizeof(input));
cout << "done" << endl;
Sleep(1000);
return;
}
However, when I declare a LPINPUT , this code compiles, but would crash when its run. The error message says input is used without being declared first. I have no clue how what that means.
Code:
#include <iostream>#include <windows.h>
#include <ctime>
using namespace std;
void main()
{
Sleep(4000);
LPINPUT input;
input[0].type = INPUT_MOUSE;
input[0].mi.dx = 0;
input[0].mi.dy = 0;
input[0].mi.mouseData = 0;
input[0].mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
input[0].mi.time = 0;
input[0].mi.dwExtraInfo = GetMessageExtraInfo();
input[1].type = INPUT_MOUSE;
input[1].mi.dx = 0;
input[1].mi.dy = 0;
input[1].mi.mouseData = 0;
input[1].mi.dwFlags = MOUSEEVENTF_RIGHTUP;
input[1].mi.time = 0;
input[1].mi.dwExtraInfo = GetMessageExtraInfo();
SendInput(2, input, sizeof(input));
cout << "done" << endl;
Sleep(1000);
return;
}
All I am trying to do is to pack multiple mouse events into one sendinput call.
thx all