如何自动点击弹窗,谢谢

delphipython 2016-11-30 08:29:31
delphi做个小程序,就是软件框体内打开网页(无其他操作,只是打开网页而已),但是网页每30分钟会出现一个js弹窗要点击确认,关于这个弹窗如何实现自动点击自动确认呢。。求代码。谢谢。
...全文
1129 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
delphipython 2016-12-10
  • 打赏
  • 举报
回复 1
谢谢各位回复。。。。。
蓝色光芒 2016-12-07
  • 打赏
  • 举报
回复

//仅仅适合32位程序
procedure TForm1.FormCreate(Sender: TObject);
var
  P : Pointer;
  Buf : array [0..7] of Byte;
  n : SIZE_T;  //低版本的Delphi 定义为 LongWord
begin
  P := GetProcAddress(GetModuleHandle('user32.dll'), 'SoftModalMessageBox');
  Buf[0] := $B8;
  Pinteger(@Buf[1])^ := ID_YES;       //设置所有MessageBox的返回值,也可以是ID_NO,ID_OK等,
  Buf[5] := $C2;
  Buf[6] := $04;
  Buf[7] := $00;
  WriteProcessMemory(GetCurrentProcess(), P , @Buf, Length(Buf), n);
  Application.MessageBox('不会弹出提示框了','AAA', MB_YESNO or MB_ICONWARNING);
end;

李_军 2016-12-06
  • 打赏
  • 举报
回复
function CallBackProc(H, HMainForm: hwnd): Boolean; stdcall; var hChild : hwnd; arr: array[0..511] of Char; str: string; begin Result := True; if GetParent(H) = HMainForm then begin //可以在这里进一步判断类名,以免关掉其他弹出窗口 EnumChildWindows(H,@CallBackSubProc, HMainForm); hChild := FindWindowEx(H, 0, PChar('Static'), ''); if hChild > 0 then begin //hChild := FindWindowEx(H, 0, PChar('Button'), PChar('确定')); ZeroMemory(@arr,512); GetWindowText(hChild,arr,512); //SendMessage(hChild, BM_Click, 0, 0); str := strPas(arr); if Trim(str)='' then begin hChild := FindWindowEx(H, hChild, PChar('Static'), ''); if hChild > 0 then begin ZeroMemory(@arr,512); GetWindowText(hChild,arr,512); str := strPas(arr); frmMain.Memo1.Lines.Add(str); end; end; //if Pos('该等级招贤馆容纳武将己达上限',str)>0 then // frmMain.Timer4.Enabled := False; if not frmMain.CloseAllMsgBox then frmMain.Timer2.Enabled := False; end; hChild := FindWindowEx(H, 0, PChar('Button'), PChar('确定')); if hChild > 0 then begin //hChild := FindWindowEx(H, 0, PChar('Button'), PChar('确定')); SendMessage(hChild, BM_Click, 0, 0); if not frmMain.CloseAllMsgBox then frmMain.Timer2.Enabled := False; end; hChild := FindWindowEx(H, 0, PChar('Button'), PChar('OK')); if hChild > 0 then begin //hChild := FindWindowEx(H, 0, PChar('Button'), PChar('确定')); SendMessage(hChild, BM_Click, 0, 0); if not frmMain.CloseAllMsgBox then frmMain.Timer2.Enabled := False; end; end; end; procedure TfrmMain.CloseSuccessInfo; //关闭操作成功的信息 //var //h: THandle; //cc: array[0..255] of Char; begin EnumWindows(@CallBackProc, Self.Handle); //Memo1.Lines.Add(StrPas(cc)); end; 这个放定时器里
Jekhn 2016-12-05
  • 打赏
  • 举报
回复
看看这个能不能帮到你
Jekhn 2016-12-05
  • 打赏
  • 举报
回复
interface 
   
uses 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  
  Dialogs, OleCtrls, SHDocVw, ActiveX;  
   
type 
  IDocHostShowUI = interface(IUnknown)  
    ['{c4d244b0-d43e-11cf-893b-00aa00bdce1a}']  
    function ShowMessage(hwnd: THandle; lpstrText: POLESTR; lpstrCaption: POLESTR;dwType: longint; lpstrHelpfile: POLESTR; dwHelpContext: longint;var plResult: LRESULT): HRESULT; stdcall;  
    function ShowHelp(hwnd: THandle; pszHelpfile: POLESTR; uCommand: integer;dwData: longint; ptMouse: TPoint; var pDispatchObjectHit: IDispatch): HRESULT; stdcall;  
  end;  
   
  TWebBrowser = class(SHDocVw.TWebBrowser,IDocHostShowUI)  
  protected 
    function ShowMessage(hwnd: THandle; lpstrText: POLESTR; lpstrCaption: POLESTR;dwType: longint; lpstrHelpfile: POLESTR; dwHelpContext: longint;var plResult: LRESULT): HRESULT; stdcall;  
    function ShowHelp(hwnd: THandle; pszHelpfile: POLESTR; uCommand: integer;dwData: longint; ptMouse: TPoint; var pDispatchObjectHit: IDispatch): HRESULT; stdcall;  
  end;  
   
   
type 
  TForm1 = class(TForm)  
    WebBrowser1: TWebBrowser;  
    procedure FormCreate(Sender: TObject);  
  private 
    { Private declarations } 
  public 
    { Public declarations } 
  end;  
   
var 
  Form1: TForm1;  
   
implementation 
   
{$R *.dfm} 
   
{ TWebBrowser } 
   
function TWebBrowser.ShowHelp(hwnd: THandle; pszHelpfile: POLESTR; uCommand,  
  dwData: Integer; ptMouse: TPoint; var pDispatchObjectHit: IDispatch): HRESULT;  
begin 
  Result := S_FALSE;  
end;  
   
function TWebBrowser.ShowMessage(hwnd: THandle; lpstrText,  
  lpstrCaption: POLESTR; dwType: Integer; lpstrHelpfile: POLESTR;  
  dwHelpContext: Integer; var plResult: LRESULT): HRESULT;  
begin 
  plResult := MessageBoxW(hwnd,PWChar(lpstrText),'Title',64);  
  Result := S_OK;  
end;  
   
procedure TForm1.FormCreate(Sender: TObject);  
begin 
  WebBrowser1.Navigate('E:/alert.htm');  
end;  
   
end.  
lyhoo163 2016-12-04
  • 打赏
  • 举报
回复
我自己编写的浏览器,就有此功能: 1、设置启动投票; 2、设置2标点击的频率,如每2分点击一次; 3、鼠标移动到投票的按键上, 这样,每2分钏,鼠标,自动点击一次。
delphipython 2016-12-03
  • 打赏
  • 举报
回复
谢谢,意思是用鼠标模拟人工的意思吧。。
不得闲 2016-12-02
  • 打赏
  • 举报
回复
这种,最好的方法是用JS去处理,如果用Delphi,那么就是MouseEvent函数去处理

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧