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
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.
Fare hareketlerimi taklid eden program yapmak istiyorum