D
DragonPC_???
Unregistered / Unconfirmed
GUEST, unregistred user!
// 获取网页的所有Elements
function GetHTMLElements(wb: TWebBrowser): IHTMLElementCollection;
var
doc: IHTMLDocument2;
begin
Result := nil;
if SUCCEEDED(wb.Document.QueryInterface(IHTMLDocument2, doc)) then
Result := doc.all;
end;
// 点击网页上面指定Caption的按键
// <INPUT TYPE="SUBMIT" NAME="scheduleConfirmed" VALUE="Sign Me Up!">
// SubmitPage(browser, 'Sign Me Up!');
function SubmitPage(wb: TWebBrowser; value: String): Boolean;
var
spDisp: IDispatch;
elements: IHTMLElementCollection;
btn: IHTMLFormElement;
i: Integer;
begin
Result := false;
elements := GetHTMLElements(wb);
for i := 0 to elements.Length - 1 do
begin
spDisp := elements.item(i, 0);
if SUCCEEDED(spDisp.QueryInterface(IHTMLFormElement, btn)) then
begin
if btn.value = value then
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
begin
btn.submit;
Result := True;
Break;
end;
end;
end;
end;
这段代码计划通过网页的按键显示的Caption来自动点击该按键,可惜奇怪的是IHTMLFormElement
没有 value 属性 ?IHTMLInputElement倒是有Value属性,可惜不能Submit,可惜的是这两个接口
实例还不能强制转换,我该如何获取IHTMLFormElement的Value属性?
function GetHTMLElements(wb: TWebBrowser): IHTMLElementCollection;
var
doc: IHTMLDocument2;
begin
Result := nil;
if SUCCEEDED(wb.Document.QueryInterface(IHTMLDocument2, doc)) then
Result := doc.all;
end;
// 点击网页上面指定Caption的按键
// <INPUT TYPE="SUBMIT" NAME="scheduleConfirmed" VALUE="Sign Me Up!">
// SubmitPage(browser, 'Sign Me Up!');
function SubmitPage(wb: TWebBrowser; value: String): Boolean;
var
spDisp: IDispatch;
elements: IHTMLElementCollection;
btn: IHTMLFormElement;
i: Integer;
begin
Result := false;
elements := GetHTMLElements(wb);
for i := 0 to elements.Length - 1 do
begin
spDisp := elements.item(i, 0);
if SUCCEEDED(spDisp.QueryInterface(IHTMLFormElement, btn)) then
begin
if btn.value = value then
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
begin
btn.submit;
Result := True;
Break;
end;
end;
end;
end;
这段代码计划通过网页的按键显示的Caption来自动点击该按键,可惜奇怪的是IHTMLFormElement
没有 value 属性 ?IHTMLInputElement倒是有Value属性,可惜不能Submit,可惜的是这两个接口
实例还不能强制转换,我该如何获取IHTMLFormElement的Value属性?