Mouse movement via SendInput results in logoff

51 Views Asked by At

SOLUTION (thanks Adrian Mole! I never would have guessed):

You must set the .time member of the MOUSEINPUT part of the union (to zero).

============

Original Question:

I am trying to move the mouse using frequent SendInput calls:

void MoveMouse(int dX, int dY)
{
    INPUT Input;
    Input.type = INPUT_MOUSE;
    Input.mi.dx = dX;
    Input.mi.dx = dY;
    Input.mi.dwFlags = MOUSEEVENTF_MOVE;
    Input.mi.time = 0;   //  <--  THIS SOLVES IT
    Input.mi.dwExtraInfo = 1234;
    SendInput(1, &Input, sizeof(Input));
}

This does work pretty much as intented, however, after a short while, the user is logged off and presented with the Windows login screen. Does anyone know how / why this could be happening, and how I could prevent this?

My google search came up blank. I tried to delay the calls with different approaches, assuming that too many SendInput's might send Windows into panic, but it still occurs seemingly at random.

0

There are 0 best solutions below