通过互联网发送鼠标位置
Sending mouse position over internet
如何从客户端 A 发送鼠标位置 =to=>SERVER=to=>客户端 B ?
下面的示例代码给我每 2 秒
一次位置输出有什么更好/更快的方法来做到这一点?
注意:使用 Winsock 和 cURL 会发出防病毒恶意软件警告
用法:用于远程控制
将鼠标位置从客户端 A 发送到服务器再到客户端 A 的当前 TEST 示例:
1.写入鼠标位置
2.store x,y 在发送.txt文件中
3.上传发送.txt作为临时.txt文件
到服务器4.删除接收.txt如果存在//错误 80 如果不存在
5.下载临时.txt作为接收.txt
6.读取接收.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;
感谢您抽出宝贵时间:)
你可能会考虑SignalR,它非常适合这些事情。有关示例,请参阅 https://pepitosolis.wordpress.com/2013/12/08/signalr-2-0-persistent-connection-another-example-tracking-your-mouse-pointer/
相关文章:
- 使用 dlib 记录鼠标位置
- 获取窗口中的鼠标位置
- 将文本添加到鼠标位置时,请单击“给出分割故障”
- 在鼠标位置移动精灵
- 如何在Mac OSX上的窗口客户端内获取真实的鼠标位置?
- 如何始终获得QT鼠标位置
- QT QgraphicView和Qgraphicscene鼠标位置
- QT:QGraphicsScene鼠标位置始终(0,0)
- SFML鼠标位置和碰撞从文件加载
- 根据鼠标位置缩小到窗口中
- 如何根据鼠标位置旋转精灵
- OpenGL获取离当前鼠标位置最近的世界三维点的三维坐标
- C++ SDL 根据鼠标位置绘制动态矩形
- 如何检索WM_COMMAND中的鼠标位置
- Qt mouseMoveEvent-跟踪鼠标位置
- OpenGl获取鼠标位置
- 获取RGBDemo的鼠标位置坐标
- 通过互联网发送鼠标位置
- 如何使用可可获得鼠标位置差异的变化
- 鼠标位置并单击 sfml 中的检测