如何从客户端 A =to=>SERVER=to=>client B 发送鼠标位置?
下面的示例代码每2 秒给我一次位置输出
有什么更好/更快的方法来做到这一点?
注意:使用 Winsock 和 cURL 会给出防病毒恶意软件警告
用法:用于远程控制
将鼠标位置从客户端 A 发送到服务器到客户端 A 的当前测试示例:
1.写入鼠标位置
2.将 x,y 存储在 send.txt 文件中
3.将 sent.txt 作为 temp.txt 文件上传到服务器
4.如果存在则删除 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 position
inp.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;
感谢您的时间 :)