怎么自动点掉webbrowser的对话框,不是要直接禁止他出现,因为有时候要点确定有时候要点取消按钮的。
类似于delphi的
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;大哥们能给出c#的代码吗?多谢啦
类似于delphi的
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;大哥们能给出c#的代码吗?多谢啦
但是delphi里面就能点掉网页的js对话框的啊,真的
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage( int hWnd, // handle to destination window int Msg, // message int wParam, // first message parameter int lParam // second message parameter );
int WM_CLOSE = 0x010;
string lpszParentWindow = "弹出窗体标题";
int ParenthWnd = (int)FindWindow(null, lpszParentWindow);
if (ParenthWnd != null)
{
//向系统发送关闭窗体指令
int WndPr = SendMessage(ParenthWnd, WM_CLOSE, 0, 0);
}
这样试试看?
public static int MK_MBUTTON = 0x0010;
int WndPr = SendMessage(ParenthWnd, MK_MBUTTON , 0, 0);
大哥,这个是不是要配合
string lpszParentWindow = "弹出窗体标题";
int ParenthWnd = (int)FindWindow(null, lpszParentWindow);
的?有没有不需要匹配窗口标题的?出现对话框就按确定或取消的代码。多谢大哥解答啊