unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
Image1: TImage;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Image1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
w,h:integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Image1.Picture.LoadFromFile('
C:\Users\RaZoR\Desktop\Unbenannt.bmp');
end;
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Label1.Caption:='
X: '+inttostr(x);
w:=x;
Label2.Caption:='
Y: '+inttostr(y);
h:=y;
end;
procedure TForm1.Image1Click(Sender: TObject);
var xFactor:real;
yFactor:real;
MousePoint:TPoint;
xstor,ystor:integer;
xRelation,yRelation:real;
begin
xFactor:=Image1.Picture.Width / Image1.Width;
yFactor:=Image1.Picture.Height / Image1.Height;
xRelation:=Screen.Width / Image1.Picture.Width;
yRelation:=Screen.Height / Image1.Picture.Height;
Label3.Caption:='
XFaktor: '+floattostr(xfactor);
Label4.Caption:='
yFaktor: '+floattostr(yfactor);
GetCursorPos(MousePoint);
xStor:=MousePoint.X;
yStor:=MousePoint.Y;
SetCursorPos(Round(w*xFactor*xRelation),Round(h*yFactor*yRelation));
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
SetCursorPos(xStor,yStor);
end;
end.