Ver Mensaje Individual
  #2  
Antiguo 24-05-2016
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.

Un ejemplo con un TButton, dos TLabel y un TSpeedButton para resaltar el mouse presionado:
Código Delphi [-]
...
implementation

const
  BTLEFTDOWN = 0;
  BTLEFTUP   = 1;

procedure ButtonLeftAction(DownUp: Integer);
var
  si: array [0..1] of TInput;
begin
  FillChar(si, SizeOf(si), 0);
  si[0].Itype      := INPUT_MOUSE;
  si[0].mi.dwFlags := MOUSEEVENTF_LEFTDOWN;
  si[1].Itype      := INPUT_MOUSE;
  si[1].mi.dwFlags := MOUSEEVENTF_LEFTUP;
  Windows.SendInput(1, tagINPUT(si[DownUp]), SizeOf(TInput));
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
  Timer1.Enabled  := False;
  Timer1.Interval := 1000;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Inc(FCount);
  Label2.Caption := Format('%d',[FCount]);
  if FCount = 5 then
  begin
    ButtonLeftAction(BTLEFTUP);
    Label1.Caption := 'Botón izquierdo liberado';
    Timer1.Enabled := False;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  p: TPoint;
  sp: TSpeedButton;
begin
  sp := SpeedButton1;
  p  := ClientToScreen(Point(sp.Left + 5, sp.Top + 5));
  SetCursorPos(p.X, p.Y);
  ButtonLeftAction(BTLEFTDOWN);
  Label1.Caption  := 'Botón izquierdo presionado';
  Label2.Caption  := '';
  FCount          := 0;  // ( Variable privada de Form1 )
  Timer1.Enabled  := True;
end;

Vista:


Saludos
__________________
Daniel Didriksen

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