Ver Mensaje Individual
  #6  
Antiguo 29-12-2013
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola look.

Siendo sincero no sé si entendí correctamente lo que buscas hacer, pero a ver si es algo así...

Cliente:
Código Delphi [-]
implementation

type
  TRecSign = record
    case IsKey : Boolean of
      False: (Point: TPoint);
      True : (Key : Word);
  end;

var
 RS: TRecSign;

procedure TfrmClient.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  RS.Point := ClientToScreen(Point(X,Y));
end;

procedure TfrmClient.FormClick(Sender: TObject);
begin
  RS.IsKey := False;
  RS.Point := ScreenToClient(Mouse.CursorPos);
  if ClientSocket1.Active then
    ClientSocket1.Socket.SendBuf(RS, SizeOf(RS));
end;

procedure TfrmClient.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  RS.IsKey := True;
  RS.Key   := Key;
  if ClientSocket1.Active then
    ClientSocket1.Socket.SendBuf(RS, SizeOf(RS));
end;

Servidor:
Código Delphi [-]
implementation

type
  TRecSign = record
    case IsKey : Boolean of
      False: (Point: TPoint);
      True : (Key : Word);
  end;

var
 RS: TRecSign;

procedure TfrmServer.ServerSocket1ClientRead(Sender: TObject; Socket: TCustomWinSocket);
var
  i:integer;
  si: array[0..1] of TInput;
begin
  with ServerSocket1.Socket do
  begin
    for i := 0 to ActiveConnections-1 do
    begin
      Connections[i].ReceiveBuf(RS, SizeOf(RS));
      if RS.isKey then
        PostMessage(ActiveControl.Handle, WM_KEYDOWN, RS.Key,
          MakeLong(0, MapVirtualKey(RS.Key, 0)))
      else
      begin
        ZeroMemory(@si, sizeof(si));
        si[0].Itype := INPUT_MOUSE;
        si[0].mi.dwFlags := MOUSEEVENTF_LEFTDOWN;
        si[1].Itype := INPUT_MOUSE;
        si[1].mi.dwFlags := MOUSEEVENTF_LEFTUP;
        RS.Point := ClientToScreen(RS.Point);
        SetCursorPos(RS.Point.X, RS.Point.Y);
        SendInput(2, si[0], SizeOf(TInput))
      end
    end;
  end;
end;

procedure TfrmServer.FormClick(Sender: TObject);
var
  P: TPoint;
begin
  P := ScreenToClient(Mouse.CursorPos);
  Caption := Format('Click en: %d %d',[P.X, P.Y]);
end;

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 29-12-2013 a las 22:53:46. Razón: identación
Responder Con Cita