Отправка позиции мыши через интернет

Как отправить позицию мыши с клиента A = to => SERVER = to => клиент B?
Пример кода ниже дает мне вывод позиции каждый 2 секунды
Какой лучший / быстрый способ сделать это?
ВНИМАНИЕ: использование Winsock и cURL выдает предупреждение антивирусной вредоносной программы.
ИСПОЛЬЗОВАНИЕ: для дистанционного управления

Текущий TEST-пример отправки позиции мыши из клиент А к СЕРВЕРУ клиенту А:

1. напишите положение мыши
2. хранить x, y в файле send.txt
3. Загрузите файл sent.txt на сервер в виде файла temp.txt.
4.remove receve.txt, если существует // ошибка 80, если нет
5. скачать temp.txt как receve.txt
6. прочитайте receve.txt и отобразите координаты в консоли

int x,y; //positions
LPCWSTR s=L"C://Documents and Settings//Administrator//Desktop//c++//FTP//send.txt";//location of file for sending
LPCWSTR r=L"C://Documents and Settings//Administrator//Desktop//c++//FTP//receve.txt";//location of received file
POINT cursor_pos;//for cursor position

HINTERNET hInternet;
HINTERNET hFtpSession;
hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if (hInternet == NULL)
{
cout << "Error: " << GetLastError();
}
else
{

hFtpSession = InternetConnect(hInternet, L"www.test.net", INTERNET_DEFAULT_FTP_PORT, L"user", L"pass", INTERNET_SERVICE_FTP, 0, 0);
if (hFtpSession == NULL)//not connect
{
cout << "Error: " << GetLastError();
}
else
{for(;;){
//file input
fstream inp;
inp.open(s);

GetCursorPos(&cursor_pos);
inp<<cursor_pos.x<<" "<<cursor_pos.y<<endl;//write curent positioninp.close();

//UPLOADING
if (!FtpPutFile(hFtpSession, s, L"//public_html//test//temp.txt", FTP_TRANSFER_TYPE_BINARY, 0))
{
cout << "ErrorPutFile: " << GetLastError();
return 0;
}remove("C://Documents and Settings//Administrator//Desktop//c++//FTP//receve.txt");//error 80 if file exist so remove it
//DOWNLOADING
if(!FtpGetFile(hFtpSession,L"//public_html//test//temp.txt",r,TRUE,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_BINARY,0))
{

cout <<"ErrorGetFile"<<GetLastError();
return 0;
}//DELETING
if(!FtpDeleteFile(hFtpSession,L"//public_html//test//temp.txt")){

cout <<"ErrorGetFile"<<GetLastError();
return 0;

}ifstream outp(r);

while(outp>>x>>y){
cout<<"X: "<<x<<" "<<"Y:"<<y<<endl;//read coordinates

}
outp.close();

}}
}

return 0;

Спасибо за ваше время 🙂

0

Решение

Вы можете рассмотреть SignalR, он отлично подходит для этих вещей. Увидеть https://pepitosolis.wordpress.com/2013/12/08/signalr-2-0-persistent-connection-another-example-tracking-your-mouse-pointer/ для примера

0

Другие решения


По вопросам рекламы [email protected]