unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 =
class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
DesktopDC: hDC;
Pos: TPoint;
implementation
{$R *.dfm}
function GetPixelFarbe: TColor;
begin
Result := GetPixel(DesktopDC, Pos.X, Pos.Y);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DesktopDC := GetDC(0);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
GetCursorPos(Pos);
if GetPixelFarbe = clGreen
then
begin
mouse_event(MOUSEEVENTF_RIGHTDOWN, Pos.x, Pos.y, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTUP, Pos.x, Pos.y, 0, 0);
end;
end;
end.