delphi做個小程式,就是軟體框體內打開網頁(無其他操作,只是打開網頁而已),但是網頁每30分鐘會出現一個js彈窗要點擊確認,關于這個彈窗如何實作自動點擊自動確認呢。。求代碼。謝謝。
uj5u.com熱心網友回復:
這種,最好的方法是用JS去處理,如果用Delphi,那么就是MouseEvent函式去處理uj5u.com熱心網友回復:
謝謝,意思是用滑鼠模擬人工的意思吧。。uj5u.com熱心網友回復:
我自己撰寫的瀏覽器,就有此功能:1、設定啟動投票;
2、設定2標點擊的頻率,如每2分點擊一次;
3、滑鼠移動到投票的按鍵上,
這樣,每2分釧,滑鼠,自動點擊一次。
uj5u.com熱心網友回復:
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.
uj5u.com熱心網友回復:
看看這個能不能幫到你uj5u.com熱心網友回復:
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;
這個放定時器里
uj5u.com熱心網友回復:
//僅僅適合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;
uj5u.com熱心網友回復:
謝謝各位回復。。。。。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/59092.html
標籤:VCL組件開發及應用
上一篇:c語言結構體
