Thema: Delphi Maus über LAN

Einzelnen Beitrag anzeigen

BasicX

Registriert seit: 19. Sep 2007
Ort: Celle
30 Beiträge
 
Delphi 2007 Professional
 
#1

Maus über LAN

  Alt 10. Dez 2008, 13:32
Hi,
habe versucht ein Programm zu schreiben, das es ermöglicht die Maus eines PCs über das Netzwerk zu steuern. Meine Funktion funktioniert auch soweit, nur dass die Positionierung auf dem 2. PC recht ruckhaft ist (kahm so auf 3 pro Sekunde). Nun meine Frage: wie kann ich das schneller hinbekommen? Der von mir genutzte Code ist folgender:

Absendender PC:
Code:
Procedure Tform1.sendposi(Sender: TObject; var Done: Boolean);
var
  MausPos : TPoint;
    diffx, diffy : integer;
begin
  getcursorpos(MausPos);
  if form2.Visible then
  begin
    diffx := Mauspos.X - floor(screen.Monitors[0].Width/2);
    diffy := Mauspos.Y - floor(screen.Monitors[0].Height/2);
    if (diffx <> 0) or (diffy <> 0) then
      IdTCPClient1.Socket.WriteLn(inttostr(diffx) + ',' + inttostr(diffy));
    SetCursorPos(floor(screen.Monitors[0].Width/2), floor(screen.Monitors[0].Height/2));
  end;
end;
(Application.OnIdle := sendposi aber auch mal als Timer getestet

Empfänger:
Code:
procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
var
  clienttext: String;
  ar: TStringdynArray;
  x,y,nx,ny: Integer;
  point: TPoint;
begin
  with AThread.Connection do begin
    clienttext := ReadLn();
    if clienttext <> 'click' then begin
      ar := Explode(',',clienttext);
      x := StrToInt(ar[0]);
      y := StrToInt(ar[1]);
      GetCursorPos(point);
      nx := point.X+x;
      ny := point.Y+y;
      SetCursorPos(nx,ny);
      //Label1.Caption := 'X' + IntToStr(x);
      //Label2.Caption := 'Y' + IntToStr(y);
    end
    else
    begin
      mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
      mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
    end;
  end;
 
end;
Bin für alle Anregungen dankbar

lg BasicX
  Mit Zitat antworten Zitat