请看下面的小代码:
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));
}
问题是编译器给了我一个plusY
未定义的警告,显然如果我尝试在已编译的插件中运行此函数(它来自插件代码,通过浏览器中的 javascript 控制台调试它)它会崩溃,因为plusY
未定义。
看来如果我不能通过if-else在函数中定义变量,那我该怎么做呢?