用webborwser访问一个url,在显示新页面的时候,会弹出一个窗口,询问是确认或取消浏览.我想问 如何实现自动对这个确认按钮进行点击.
页面内容如下:
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="colorring.css" rel="stylesheet" type="text/css">
<link href="images/blue/color.css" rel="stylesheet" type="text/css">
</head>
<script src="pubfun/JsFun.js"></script><body leftmargin="0" topmargin="0"><form name="inputForm" method="post" action="largess.jsp">
<input type="hidden" name="id" value="1234">
<input type="hidden" value="123456789" name="phone">
<input type="hidden" value="" name="leavewords">
</form>
<script language="JavaScript">
var strConfirm = "您确认要浏览吗?";
if (confirm(strConfirm)) {
document.inputForm.submit();
}
else{
document.URL = '?grouptype=1';
}
</script>
</body>
</html>
页面内容如下:
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="colorring.css" rel="stylesheet" type="text/css">
<link href="images/blue/color.css" rel="stylesheet" type="text/css">
</head>
<script src="pubfun/JsFun.js"></script><body leftmargin="0" topmargin="0"><form name="inputForm" method="post" action="largess.jsp">
<input type="hidden" name="id" value="1234">
<input type="hidden" value="123456789" name="phone">
<input type="hidden" value="" name="leavewords">
</form>
<script language="JavaScript">
var strConfirm = "您确认要浏览吗?";
if (confirm(strConfirm)) {
document.inputForm.submit();
}
else{
document.URL = '?grouptype=1';
}
</script>
</body>
</html>
www.51merit.com
看看!
procedure TFrmMain.Timer2Timer(Sender: TObject);
var
H: HWND;
text: array[0..255] of char;
s: string;
begin
h := findwindow(nil, 'Internet Explorer 脚本错误'); //查找到窗口#32770,&#8217;#32770&#8216;用spy++查出来的。 if H > 0 then SendMessage(h, WM_SYSCOMMAND, SC_CLOSE, 0); h := findwindow(nil, 'Microsoft Internet Explorer'); //查找到窗口#32770,&#8217;#32770&#8216;用spy++查出来的。
if H > 0 then SendMessage(h, WM_SYSCOMMAND, SC_CLOSE, 0); h := findwindow(nil, '添加到收藏夹'); //查找到窗口#32770,&#8217;#32770&#8216;用spy++查出来的。
if H > 0 then SendMessage(h, WM_SYSCOMMAND, SC_CLOSE, 0); h := findwindow(nil, '安全警报'); //查找到窗口#32770,&#8217;#32770&#8216;用spy++查出来的。
if H > 0 then SendMessage(h, WM_SYSCOMMAND, SC_CLOSE, 0);
h := findwindow(nil, 'Symantec AntiVirus 通知'); //查找到窗口#32770,&#8217;#32770&#8216;用spy++查出来的。
if H > 0 then SendMessage(h, WM_SYSCOMMAND, SC_CLOSE, 0); h := GetActiveWindow();
GetWindowText(h, @text, 255);
s := strpas(text);
if pos('Microsoft Internet Explorer', s) > 0 then SendMessage(h, WM_SYSCOMMAND, SC_CLOSE, 0); //回位于最顶部的具有输入焦点的窗口句柄
end;
keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), 0, 0);
keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), KEYEVENTF_KEYUP,0);
我用你的方法试过了,不行
procedure TForm1.Timer1Timer(Sender: TObject);
var
H,hc: HWND;begin
Timer1.Enabled := False;
if H > 0 then SendMessage(h, WM_SYSCOMMAND, SC_CLOSE, 0); } h := findwindow(nil, 'Microsoft Internet Explorer'); if H > 0 then
begin
hc := FindWindowEx(h,0,'Button','确定');
SendMessage(hc, BM_CLICK, 0, 0);
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
H,hc: HWND;begin
Timer1.Enabled := False;
h := findwindow(nil, 'Microsoft Internet Explorer');
if H > 0 then
begin
hc := FindWindowEx(h,0,'Button','确定');
SendMessage(hc, BM_CLICK, 0, 0);
end;
end;