写了个简单的投票机

procedure TForm1.FormShow(Sender: TObject);
begin
  WebBrowser1.Navigate('http://kejiao.cntv.cn/program/jingli2012/index.shtml');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Timer1.Enabled:=true;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  webbrowser1.OleObject.document.parentWindow.execScript('makeVote(13824,75904)','JavaScript');

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Timer1.Enabled:=false;
end;
//关掉alert弹出窗口
function CallBackProc(H, HMainForm: hwnd): Boolean; stdcall;
var
  hChild : hwnd;
begin
  Result := True;
  if GetParent(H) = HMainForm then begin 
    hChild := FindWindowEx(H, 0, PChar('Button'), PChar('确定'));
    if hChild > 0 then SendMessage(hChild, BM_Click, 0, 0);
  end;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
  try
   EnumWindows(@CallBackProc, Self.Handle);
   except
   end;
end;

你可能感兴趣的:(简单)