硬件外掛基礎-看我來山寨按鍵盒子
源碼如下:
unit Unit10;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,Dm_TLB,ComObj,madKernel, ExtCtrls, SPComm;
type
TForm10 = class(TForm)
btn1: TButton;
tmr1: TTimer;
lbl1: TLabel;
cm1: TComm;
btn2: TButton;
cbb1: TComboBox;
procedure FormCreate(Sender: TObject);
procedure tmr1Timer(Sender: TObject);
procedure leftclick();
procedure rightclick();
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btn1Click(Sender: TObject);
procedure btn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form10: TForm10;
plug:dmsoft;
implementation
{$R *.dfm}
procedure TForm10.btn2Click(Sender: TObject);
begin
cm1.CommName:=cbb1.Text;
cm1.StartComm;
tmr1.Enabled:=True;
btn2.Enabled:=False;
end;
procedure TForm10.FormClose(Sender: TObject; var Action: TCloseAction);
begin
cm1.StopComm;
end;
procedure TForm10.FormCreate(Sender: TObject);
begin
Plug:=CreateComObject(CLASS_dmsoft) as dmsoft;
end;
procedure TForm10.leftclick;
begin
cm1.WriteCommData(a,1);
end;
procedure TForm10.rightclick;
begin
cm1.WriteCommData(b,1);
end;
procedure TForm10.btn1Click(Sender: TObject);
begin
tmr1.Enabled:=False;
cm1.StopComm;
Self.Close;
end;
procedure TForm10.tmr1Timer(Sender: TObject);
var
x,y:OleVariant;
isfind:Integer;
begin
begin
isfind:=Plug.FindColor(370,350,430,351,AE3D2B,0.9,2,X,Y);
if isfind=1 then
begin
leftclick;
Sleep(30);
leftclick;
end;
Sleep(20);
end;
end;
end.
好了 就說這么多了,可能有的地方沒說全,下次再補補吧,好晚了,明天還要出差。
其實這個只是最最簡單的硬件控制方案了,呵呵,無奈水平有限只能做個這個出來了,以后有時間再研究了!
評論