if
(dwCommand == REMOTE_MOUSE_POS)
{
DWORD
dwDataSize = lphdr->packlen;
if
(dwDataSize =
sizeof
(POINT) +
sizeof
(POINT))
{
LPREMOTECONTROLPOS pos = (LPREMOTECONTROLPOS)(lpBuf +
sizeof
(NETWORKPACKETHEADER));
POINT stServerCurrent = pos->pos;
POINT stPtServerMax = pos->size;
int
iXLocalMax = ScrnResolutionX;
int
iYLocalMax = ScrnResolutionY;
POINT stPtLocalCurrent = { 0 };
if
(stPtServerMax.x != 0 && stPtServerMax.y != 0)
{
stPtLocalCurrent.x = (iXLocalMax * stServerCurrent.x) / stPtServerMax.x;
stPtLocalCurrent.y = (iYLocalMax * stServerCurrent.y) / stPtServerMax.y;
lpSetCursorPos(stPtLocalCurrent.x, stPtLocalCurrent.y);
}
}
actionInterval(&dwSleepTimeValue);
continue
;
}
else
if
(dwCommand == REMOTE_KEYBOARD)
{
if
(lphdr->packlen == 2)
{
LPREMOTECONTROLKEY lpkey = (LPREMOTECONTROLKEY)(lpBuf +
sizeof
(NETWORKPACKETHEADER));
unsigned
char
key = lpkey->key;
unsigned
char
keyshift = lpkey->shiftkey;
if
(keyshift)
{
keybd_event(VK_SHIFT, 0, 0, 0);
keybd_event(key, 0, 0, 0);
keybd_event(key, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
}
else
{
keybd_event(key, 0, 0, 0);
keybd_event(key, 0, KEYEVENTF_KEYUP, 0);
}
}
actionInterval(&dwSleepTimeValue);
continue
;
}
else
if
(dwCommand == REMOTE_LEFTBUTTONDOWN || dwCommand == REMOTE_LEFTBUTTONDOUBLECLICK ||
dwCommand == REMOTE_RBUTTONDOWN || dwCommand == REMOTE_RBUTTONDOUBLECLICK)
{
DWORD
dwDataSize = lphdr->packlen;
if
(dwDataSize =
sizeof
(POINT) +
sizeof
(POINT))
{
LPREMOTECONTROLPOS pos = (LPREMOTECONTROLPOS)(lpBuf +
sizeof
(NETWORKPACKETHEADER));
POINT stServerCurrent = pos->pos;
POINT stPtServerMax = pos->size;
int
iXLocalMax = ScrnResolutionX;
int
iYLocalMax = ScrnResolutionY;
POINT stPtLocalCur = { 0 };
if
(stPtServerMax.x != 0 && stPtServerMax.y != 0)
{
stPtLocalCur.x = (iXLocalMax * stServerCurrent.x) / stPtServerMax.x;
stPtLocalCur.y = (iYLocalMax * stServerCurrent.y) / stPtServerMax.y;
lpSetCursorPos(stPtLocalCur.x, stPtLocalCur.y);
if
(dwCommand == REMOTE_LEFTBUTTONDOWN)
{
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
}
else
if
(dwCommand == REMOTE_RBUTTONDOWN)
{
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
}
else
if
(dwCommand == REMOTE_RBUTTONDOUBLECLICK)
{
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
lpSleep(0);
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
}
else
if
(dwCommand == REMOTE_LEFTBUTTONDOUBLECLICK)
{
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
lpSleep(0);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
}
}
}
actionInterval(&dwSleepTimeValue);
continue
;
}
else
if
(dwCommand == REMOTE_MOUSEWHEEL)
{
DWORD
dwDataSize = lphdr->packlen;
if
(dwDataSize =
sizeof
(
DWORD
) +
sizeof
(
DWORD
))
{
LPREMOTECONTROLWHEEL wheel = (LPREMOTECONTROLWHEEL)(lpBuf +
sizeof
(NETWORKPACKETHEADER));
int
key = wheel->delta & 0xffff;
int
delta = wheel->delta >> 16;
int
x = wheel->xy & 0xffff;
int
y = wheel->xy & 0xffff0000;
mouse_event(MOUSEEVENTF_WHEEL, x, y, delta, 0);
lpSleep(0);
}
actionInterval(&dwSleepTimeValue);
continue
;
}
else
if
(dwCommand == RECV_DATA_OK || dwCommand == REMOTE_DUMMY_PACKET)
{
freeInterval(&dwSleepTimeValue);
}
else
if
(dwCommand == REMOTECONTROL_END)
{
writeLog(
"remotecontrol shutdown by server\r\n"
);
break
;
}
else
{
writeLog(
"RemoteControlProc unrecognized command:%u\r\n"
, dwCommand);
}
checkTime(&dwSleepTimeValue);