//新年快乐!!!!还在工作吗? procedure TForm1.Button4Click(Sender: TObject); var i:integer; t:OleVariant; begin t := WebBrowser1.Document; for i := 0 to t.all.length - 1 do begin if t.all.item(i).tagName = 'INPUT' then begin if t.all.item(i).name = '否按钮的name' then begin t.all.item(i).click; exit; end; end; end; end;
to scyaan 新年快乐! 我按照你的方法进行了,不行。按钮是在弹出的窗口上 我把我的代码贴出来,请你帮忙看下,谢谢 procedure TFrmMain.Timer2Timer(Sender: TObject); var H,hc: HWND; i:integer; t:OleVariant; begin h := findwindow(nil,'Microsoft Internet Explorer'); if H > 0 then begin hc := FindWindowEx(h,0,'Button','确定'); if hc>0 then begin SendMessage(hc, BM_CLICK, 0, 0); end else begin t := WebBrowser1.Document; for i:=0 to t.all.length-1 do begin if t.all.item(i).name='否'then t.all.item(i).click; end; end; end; end;
PostMessage(FindWindow(nil,''Microsoft Internet Explorer'),VK_RETURN,13,0);
to rainstormmaster 弹出窗体的对话框已经找出来了。 var H,hc: HWND; i:integer; t:OleVariant; begin h := findwindow(nil,'Microsoft Internet Explorer'); if H > 0 then begin hc := FindWindowEx(h,0,'Button','确定'); if hc>0 then begin SendMessage(hc, BM_CLICK, 0, 0); end else begin t := WebBrowser1.Document; for i:=0 to t.all.length-1 do begin if t.all.item(i).name='否'then t.all.item(i).click; end; end; end; end;
to leafv(leafv):大虾真厉害啊,参考一下你的代码,不过后面这几行有些不明白,->for i:=0 to t.all.length-1 do begin if t.all.item(i).name='否'then t.all.item(i).click; end;如果用javascript的角度来看应该是在Document内模拟点击名为'否'的对象,这个动作小弟有些不解,还望大虾指教,楼主的动作小弟觉得在一些情况下还是很有用的啊,比如浏览一些网站时,网页不断弹出'将本页设为主页的'对话框,直到设为主页后才不弹出,但小弟不知道怎么实现跳过个动作,直接SendMessage吗,还望大虾们指教一下啊!!!祝天下好心人新年快乐!!!
javascript? it can not do it.Don't visit this kind of web site, or update to Windows XP SP2. setHomePage() will fail with an access denied error if it is not called within a user initiated context.Personally, I use about:blank as my home page because the browser window opens faster.
javascript? it can not do it. ------- 小弟不是说用Javascript来实现,只是在概念上认为而以,算是相当于吧,纯属个人看法,请大虾别见怪哈!!!Don't visit this kind of web site, or update to Windows XP SP2. setHomePage() will fail with an access denied error if it is not called within a user initiated context. ------- 这句话小弟实在是看不懂,不知可否劳烦楼上大虾用中文解释一下,谢谢!!! Don't visit this kind of web site ------- 不要访问这样的网站小弟也不想的啊,有时候无意中点了,就没办法了。最看不懂的是下面这句: setHomePage() will fail with an access denied error if it is not called within a user initiated context.
to qsdnet var H,hc: HWND; i:integer; begin h := findwindow(nil,'Microsoft Internet Explorer'); if H > 0 then begin hc := FindWindowEx(h,0,'Button','确定'); if hc>0 then begin SendMessage(hc, BM_CLICK, 0, 0); end end; end;原来的代码有问题.
procedure TForm1.Button4Click(Sender: TObject);
var
i:integer;
t:OleVariant;
begin
t := WebBrowser1.Document;
for i := 0 to t.all.length - 1 do
begin
if t.all.item(i).tagName = 'INPUT' then
begin
if t.all.item(i).name = '否按钮的name' then
begin
t.all.item(i).click;
exit;
end;
end;
end;
end;
新年快乐!
我按照你的方法进行了,不行。按钮是在弹出的窗口上
我把我的代码贴出来,请你帮忙看下,谢谢
procedure TFrmMain.Timer2Timer(Sender: TObject);
var
H,hc: HWND;
i:integer;
t:OleVariant;
begin
h := findwindow(nil,'Microsoft Internet Explorer');
if H > 0 then
begin
hc := FindWindowEx(h,0,'Button','确定');
if hc>0 then
begin
SendMessage(hc, BM_CLICK, 0, 0);
end
else
begin
t := WebBrowser1.Document;
for i:=0 to t.all.length-1 do
begin
if t.all.item(i).name='否'then
t.all.item(i).click;
end;
end;
end;
end;
<head>
<title>组成员管理</title>
<link rel="stylesheet" type="text/css" href="../../style.css">
</head>
<body topmargin="0" leftmargin="0" class="body-style1"><script language="javascript">
var ringdisplay = "音乐";
function addRing () {
var fm = document.inputForm;
if ((fm.outRing.selectedIndex) < 0) {
alert('请选择添加到' + ringdisplay + '组中的' + ringdisplay + '!');
return;
}
fm.op.value = 'add';
fm.crid.value = fm.outRing.value;
fm.submit();
} function delRing () {
var fm = document.inputForm;
if ((fm.inRing.selectedIndex) < 0) {
alert('请选择从' + ringdisplay + '组中删除的' + ringdisplay + '!');
return;
}
fm.op.value = 'del';
fm.crid.value = fm.inRing.value;
fm.submit();
}
function windowClose(){
window.close();
}
</script>
<form name="inputForm" method="post" action="ringMember.jsp">
<input type="hidden" name="op" value="">
<input type="hidden" name="crid" value="">
<input type="hidden" name="craccount" value="1234567890123">
<input type="hidden" name="ringgroup" value="100000001">
<input type="hidden" name="grpLabel" value="默认组"> <b><font class="font"> 组成员管理</font></b></font></td>
<tr>
<td colspan="3">您正在编辑的组是 100000001-默认组</td>
</tr>
<tr class="table-styleshow">
<td>组中拥有的音乐</td>
<td> </td>
<td>组未拥有的音乐</td>
</tr>
<tr> <td>
<select name="inRing" size="8" class="select-style3">
<option value="330005" selected>330005-----------超级1</option>
<option value="330006" selected>330006-----------超级2</option>
</select> </td>
<td align="center" valign="center"> <input type="button" name="add2" value="<<" onclick="javascript:addRing()" >
<p> <p>
<input type="button" name="del" value=">>" onclick="javascript:delRing()" >
</td>
<td>
<select name="outRing" size="8" class="select-style3">
<option value="2100015">21000615-----------超级3</option>
<option value="210001388">210001388-----------超级3</option>
</select> </td>
</tr>
<tr>
<td colspan="3">
<table border="0" width="100%" class="table-style2">
<tr>
<td align="center"><img src="../../button/close.gif" onmouseover="this.style.cursor='hand'" onclick="javascript:windowClose()"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td width="100%">
<table width="90%" cellspacing="1" cellpadding="2" border="0" class="table-style2">
<tr>
<td class="table-styleshow" background="../../image/n-9.gif" height="26">
帮助信息:</td>
</tr>
<tr>
<td>1.点击“<<”按钮,把音乐添加到组中;</td>
</tr>
<tr>
<td>2.点击“>>”按钮,把音乐从组中删除;</td>
当从 组未拥有的音乐 中选择某个音乐到 组中拥有的音乐 时,如果选择的音乐在 组中拥有的音乐 已经存在,则会弹出一个窗口。 窗口上有两个按钮,是,否。默认按钮 是。我现在想选择 否。请问要如何操作呢。
窗口上按钮分别: 是(Y) 否(N) y,n下面都有下发线。
就是javascript的confirm的对话框。请你教我下如何枚举窗口呢。最好可以把代码贴出来给我看下。谢谢最后向在节日继续奋战在工作第一线的同志问拜年!祝各位大虾新春快乐!!!
弹出窗体的对话框已经找出来了。
var
H,hc: HWND;
i:integer;
t:OleVariant;
begin
h := findwindow(nil,'Microsoft Internet Explorer');
if H > 0 then
begin
hc := FindWindowEx(h,0,'Button','确定');
if hc>0 then
begin
SendMessage(hc, BM_CLICK, 0, 0);
end
else
begin
t := WebBrowser1.Document;
for i:=0 to t.all.length-1 do
begin
if t.all.item(i).name='否'then
t.all.item(i).click;
end;
end;
end;
end;
begin
if t.all.item(i).name='否'then
t.all.item(i).click;
end;如果用javascript的角度来看应该是在Document内模拟点击名为'否'的对象,这个动作小弟有些不解,还望大虾指教,楼主的动作小弟觉得在一些情况下还是很有用的啊,比如浏览一些网站时,网页不断弹出'将本页设为主页的'对话框,直到设为主页后才不弹出,但小弟不知道怎么实现跳过个动作,直接SendMessage吗,还望大虾们指教一下啊!!!祝天下好心人新年快乐!!!
-------
小弟不是说用Javascript来实现,只是在概念上认为而以,算是相当于吧,纯属个人看法,请大虾别见怪哈!!!Don't visit this kind of web site, or update to Windows XP SP2. setHomePage() will fail with an access denied error if it is not called within a user initiated context.
-------
这句话小弟实在是看不懂,不知可否劳烦楼上大虾用中文解释一下,谢谢!!!
Don't visit this kind of web site
-------
不要访问这样的网站小弟也不想的啊,有时候无意中点了,就没办法了。最看不懂的是下面这句:
setHomePage() will fail with an access denied error if it is not called within a user initiated context.
var
H,hc: HWND;
i:integer;
begin
h := findwindow(nil,'Microsoft Internet Explorer');
if H > 0 then
begin
hc := FindWindowEx(h,0,'Button','确定');
if hc>0 then
begin
SendMessage(hc, BM_CLICK, 0, 0);
end
end;
end;原来的代码有问题.