Please see the small code below:
void TestPluginAPI::MouseMove(int nX, int nY)
{
INPUT input;
DOUBLE fScreenWidth = GetSystemMetrics( SM_CXSCREEN )-1;
DOUBLE fScreenHeight = GetSystemMetrics( SM_CYSCREEN )-1;
int plusY;
if (FullScreenCheck() == 1) {int plusY = getmidY() + 8.0f;}
else {int plusY = getmidY();}
int plusX = getmidX();
DOUBLE fX = plusX*(65535.0f/fScreenWidth) + (nX*(65535.0f/fScreenWidth));
DOUBLE fY = plusY*(65535.0f/fScreenHeight) + (nY*(65535.0f/fScreenHeight));
RtlZeroMemory(&input, sizeof(input));
input.type = INPUT_MOUSE;
input.mi.dwFlags = MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE;
input.mi.dx = (LONG)fX;
input.mi.dy = (LONG)fY;
SendInput(1, &input, sizeof(input));
}
The thing is that the compiler gives me a warning, that plusY
is undefined, and obviously if I try to run this function in a compiled plugin (it's from plugin code, debugging it thru javascript console in a browser) it crashes because plusY
is undefined.
It seems that if I can't define variables in function through if-else, then how can I do this?