客户端:
procedure TForm1.Image1DblClick(Sender: TObject);
begin
clientsocket1.Socket.SendText(inttostr(cx)+'ssdouble'+inttostr(cy));
end;
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
cx:=x;
cy:=y;
if shift=[ssleft] then
begin
clientsocket1.Socket.SendText(inttostr(x)+'ssleft'+inttostr
);
end;
if shift=[ssright] then
begin
clientsocket1.Socket.SendText(inttostr(x)+'ssright'+inttostr
);
end;
end;
cx,cy是两个自定义变量.
服务器端:
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var
s:string;
s2
char;
sx,sy:integer
begin
s:=socket.ReceiveText;
s2:=pchar(s);
if strpos(s2,'ssdouble')<>nil then
begin
sx:=strtoint(copy(s,1,strpos(s2,'ssdouble')-s2));
sy:=strtoint(copy(s,(strpos(s2,'ssdouble')-s2)+9,length(s)-(strpos(s2,'ssdouble')-s2)-8));
setcursorpos(sx,sy);
mouse_event(MOUSEEVENTF_LEFTDOWN, sx, sy, 0, 0 );
mouse_event(MOUSEEVENTF_LEFTUP, sx, sy, 0, 0 );
mouse_event(MOUSEEVENTF_LEFTDOWN, sx, sy, 0, 0 );
mouse_event(MOUSEEVENTF_LEFTUP, sx, sy, 0, 0 );
end;
if strpos(s2,'ssleft')<>nil then
begin
sx:=strtoint(copy(s,1,strpos(s2,'ssleft')-s2));
sy:=strtoint(copy(s,(strpos(s2,'ssleft')-s2)+7,length(s)-(strpos(s2,'ssdouble')-s2)-6));
setcursorpos(sx,sy);
mouse_event(MOUSEEVENTF_LEFTDOWN, sx, sy, 0, 0 );
mouse_event(MOUSEEVENTF_LEFTUP, sx, sy, 0, 0 );
end;
if strpos(s2,'ssright')<>nil then
begin
sx:=strtoint(copy(s,1,strpos(s2,'ssright')-s2));
sy:=strtoint(copy(s,(strpos(s2,'ssright')-s2)+8,length(s)-(strpos(s2,'ssright')-s2)-7));
setcursorpos(sx,sy);
mouse_event(MOUSEEVENTF_RIGHTDOWN, sx, sy, 0, 0 );
mouse_event(MOUSEEVENTF_RIGHTUP, sx, sy, 0, 0 );
end;
end;