Arama butonu
Bu konudaki kullanıcılar: 1 misafir, 1 mobil kullanıcı
1
Cevap
1549
Tıklama
0
Öne Çıkarma
Delphi Mouse Event
H
18 yıl (15 mesaj)
Er
Konu Sahibi

Aşağıdaki program delphi de benim yaptığım hareketleri taklid etmesini sağlamak istiyorum.
Hareketler tamam ama tıklama olmadı. Programımın dışında tıklamaları nasıl takip ederim


unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, AppEvnts, ExtCtrls;

type
TForm1 = class(TForm)
Timer1: TTimer;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure aeMessage(var Msg: tagMSG; var Handled: Boolean);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure MyMouseEvent(var Msg: TMsg; var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
mos:tpoint;
ass:Tmouse;
coords : array[1..100000, 1..3] of Integer;
i : Integer;
mode : Integer ;
max : Integer;

implementation
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
mode:= 1;
i:=0;
end;

procedure TForm1.aeMessage(var Msg: tagMSG; var Handled: Boolean);
begin
{ edit1.Text:=inttostr(msg.pt.X);
edit2.Text:=inttostr(msg.pt.y); }
coords[i,1] := msg.pt.X;
coords[i,2] := msg.pt.Y;
i := i+1;
max := i;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
ass:=Tmouse.Create;
i:=1;
max := 0;
mode := 0;
Application.OnMessage := MyMouseEvent;

end;

procedure mouseclick() ;
begin
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
if (mode = 2 ) then
begin
{ edit1.Text:=inttostr(ass.CursorPos.X);
edit2.Text:=inttostr(ass.CursorPos.y); }
coords[i,1] := ass.CursorPos.X;
coords[i,2] := ass.CursorPos.Y;
i := i+1;
max := i;
end;

if (mode = 1) then
begin
mos.X:=coords[i,1];
mos.Y:=coords[i,2];
ass.CursorPos:=mos;
case coords[i,3] of
1 : mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
2 : mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
3 : mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
4 : mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
end;
i := i +1;
if (i >= max) then
begin
mode:=0;
i:=0;
end;
end;

end;


procedure TForm1.Button2Click(Sender: TObject);
begin
mode:= 2;
i:=0;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
mode:= 1;
i:= 0;
end;

procedure TForm1.MyMouseEvent(var Msg: TMsg; var Handled: Boolean);
begin
case Msg.message of
wm_LButtonDown: coords[i-1,3] := 1;
WM_LBUTTONUP: coords[i-1,3] := 2;
WM_RBUTTONDOWN : coords[i-1,3] := 3;
WM_RBUTTONUP : coords[i-1,3] := 4;
end;
end;


end.

DH forumlarında vakit geçirmekten keyif alıyor gibisin ancak giriş yapmadığını görüyoruz.

Üye olduğunda özel mesaj gönderebilir, beğendiğin konuları favorilerine ekleyip takibe alabilir ve daha önce gezdiğin konulara hızlıca erişebilirsin.

Üye Ol Şimdi Değil



H
18 yıl (15 mesaj)
Er
Konu Sahibi

Fare hareketlerimi taklid eden program yapmak istiyorum



DH Mobil uygulaması ile devam edin. Mobil tarayıcınız ile mümkün olanların yanı sıra, birçok yeni ve faydalı özelliğe erişin. Gizle ve güncelleme çıkana kadar tekrar gösterme.