Home > Back-end >  How to automatically click the pop-up window, thank you
How to automatically click the pop-up window, thank you

Time:09-21

Delphi do a small program, is open web software box body (no other operations, just open the web page), but the web every 30 minutes will be a js popup window click on the confirmation, about how the modal window automatically click the automatic confirmation, and strives for the code, thank you.

CodePudding user response:

This, the best method is to use JS to deal with, if use the Delphi, then MouseEvent function to deal with

CodePudding user response:

Thank you, means to use the mouse to simulate artificial mean,,

CodePudding user response:

I write your own browser, there is this function:
1, set the start voting;
2, click set up 2 standard frequency, such as once every 2 minutes and click;
3, the buttons on the mouse moves to vote,

In this way, each about 2 minutes, the mouse, click once, automatically

CodePudding user response:

 interface 

USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls SHDocVw, ActiveX;

Type
IDocHostShowUI=interface (IUnknown)
[' {cf c4d244b0 - d43e - 11-893-00 aa00bdce1a b} ']
The function ShowMessage (HWND: THandle; LpstrText: POLESTR; LpstrCaption: POLESTR; DwType: longint; LpstrHelpfile: POLESTR; DwHelpContext: longint; Var plResult: LRESULT) : HRESULT; Stdcall;
The function ShowHelp (HWND: THandle; PszHelpfile: POLESTR; UCommand: integer; DwData: longint; PtMouse: TPoint; Var pDispatchObjectHit: IDispatch) : HRESULT; Stdcall;
end;

TWebBrowser=class (SHDocVw TWebBrowser, IDocHostShowUI)
Protected
The function ShowMessage (HWND: THandle; LpstrText: POLESTR; LpstrCaption: POLESTR; DwType: longint; LpstrHelpfile: POLESTR; DwHelpContext: longint; Var plResult: LRESULT) : HRESULT; Stdcall;
The 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}

The function TWebBrowser. ShowHelp (HWND: THandle; PszHelpfile: POLESTR; UCommand,
DwData: Integer; PtMouse: TPoint; Var pDispatchObjectHit: IDispatch) : HRESULT;
The begin
Result:=S_FALSE;
end;

The function TWebBrowser. ShowMessage (HWND: THandle; LpstrText,
LpstrCaption: POLESTR; DwType: Integer; LpstrHelpfile: POLESTR;
DwHelpContext: Integer; Var plResult: LRESULT) : HRESULT;
The begin
PlResult:=MessageBoxW (HWND, PWChar (lpstrText), 'Title', 64);
Result:=S_OK;
end;

Procedure TForm1. FormCreate (Sender: TObject);
The begin
WebBrowser1. Navigate (' E:/alert. HTM);
end;

End.

CodePudding user response:

See if this can help you

CodePudding user response:

The function CallBackProc (H, HMainForm: HWND) : Boolean; Stdcall;
Var
HChild: HWND;
Arr: an array of Char [0.. 511];
STR: string;
The begin
Result:=True;

If GetParent (H)=HMainForm then
Begin here//can further determine the name of the class, so as not to turn off other pop-up window
EnumChildWindows (H, @ CallBackSubProc HMainForm);





HChild:=FindWindowEx (H, 0, PChar (" Static "), ");
If hChild & gt; 0 then
The begin
//hChild:=FindWindowEx (H, 0, PChar (" Button "), PChar (' sure '));
ZeroMemory (@ arr, 512);
GetWindowText (hChild, arr, 512);
//SendMessage (hChild BM_Click, 0, 0);
STR:=strPas (arr);
If the Trim (STR)='then
The begin
HChild:=FindWindowEx (H, hChild, PChar (" Static "), ");
If hChild & gt; 0 then
The begin
ZeroMemory (@ arr, 512);
GetWindowText (hChild, arr, 512);
STR:=strPas (arr);
FrmMain. Memo1. Lines. The Add (STR);
end;
end;

//if Pos (' the level of the pap pavilion accommodate blow yourself up to upper limit ', STR) & gt; 0 then
//frmMain. Timer4. Enabled:=False;
If not frmMain. CloseAllMsgBox then
FrmMain. Timer2. Enabled:=False;
end;

HChild:=FindWindowEx (H, 0, PChar (" Button "), PChar (' sure '));
If hChild & gt; 0 then
The begin
//hChild:=FindWindowEx (H, 0, PChar (" Button "), PChar (' sure '));

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 & gt; 0 then
The begin
//hChild:=FindWindowEx (H, 0, PChar (" Button "), PChar (' sure '));

SendMessage (hChild BM_Click, 0, 0);
If not frmMain. CloseAllMsgBox then
FrmMain. Timer2. Enabled:=False;

end;

end;
end;

Procedure TfrmMain. CloseSuccessInfo;//close operation successful information
//var
//h: THandle;
//cc: an array of Char [0.. 255];
The begin
EnumWindows (@ CallBackProc, Self. Handle);
//Memo1. Lines. The Add (StrPas (cc));
end;

The put a timer

CodePudding user response:

 
//only suitable for 32-bit programs
Procedure TForm1. FormCreate (Sender: TObject);
Var
P: Pointer;
Buf: an array of Byte [0.. 7];
N: SIZE_T;//low version of Delphi defined as LongWord
The begin
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related