Internet Explorer对象... [英] Internet Explorer object...

查看:71
本文介绍了Internet Explorer对象...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,没有原生VB.NET相当于VB6 Web

浏览器控件。我可以使用HTML明智地玩一些东西,但没有一个

做我真正需要做的事情(这最终是以DOM&

编程点击中的元素DOM)。


我正在尝试通过使用

网络浏览器控制重建我在VB6中完成的一些东西com互操作。救命!它表现不同

然后我习惯了,我不知道从哪里开始...


我最重要的事件之一我想要完成的是

DocumentComplete事件。每当框架或iFrame中的文档加载到网页

浏览器中时,DocumentComplete就会触发(或者至少应该触发)




对于我需要做的事情(我在VB6中完美运行)我需要

等待一定数量的docComplete事件再继续其余的

代码。在VB6中,这没有问题。我编写的方法导航

只是查看我声明的每次
doComplete触发时都会增加的属性。 VB6的愚蠢是可爱的,只要属性不是X(同时),我的方法将实际停止。


同样的逻辑确实如此不在dotnet工作。我有一个导航方法,并且在

类级别我声明了一个withevents变量。如果我在我的导航方法中放了一个Do ...而且是封装检查属性值,那么它将永远不会释放,而且docComplete事件永远不会触发。如果我拿走了...

在外出时,那么doComplete会触发,但直到我的导航方法是

已经完成...

显然我是一个dotnetnewbie ....我做错了什么?

As far as I understand there is no native VB.NET equivalent of the VB6 Web
browser control. There are some things I can play with HTML wise, but none
do what I really need to do (which is ultimately walk the DOM &
programatically click on elements in the DOM).

I am trying to rebuild some of the stuff I''ve done in VB6 in dotnet by using
the web browser control thru the com interop. HELP! It behaves different
then I am used to and I am not sure where to go from here...

One of the most important events in what I am trying to accomplish is the
DocumentComplete event. The DocumentComplete fires (or at least should fire)
every time a document in a frame or an iFrame is done loading in the web
browser.

For what I need to do (and I have this working perfectly in VB6) I need to
wait an X amount of docComplete events before continuing with the rest of
the code. In VB6 this is no problem. The method I write that navigates
simply looks at a property I declared that gets upped by one every time the
doComplete fires. VB6 is lovely in its stupidity that my method will
actually halt for as long as the property is not X (Do while).

This same logic does not work in dotnet. I have a navigate method and at the
class level I declare a withevents variable. If I put a Do... While
(encapsulating the check for the property value) in my navigate method, it
never releases and the docComplete event never fires. If I take the Do...
While out, then the doComplete fires but not until my navigate method is
already finished...

Obviously I am a dotnetnewbie.... What am I doing wrong??

推荐答案

VBSome


我不知道你做错了什么,不过这里有一个非常简单的方法来使用

AXwebbrowser(与VB6相同)。


打开一个新的Windows应用程序项目


在工具箱中右键单击并选择添加/删除项目


在自定义工具箱中选择Com并在那个Microsoft Webbrowser中


当它在工具箱中时将它拖到你的表单上

拖动一个按钮到你的表单。


然后这个代码和你有一个迷你Web浏览器。

Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理Button1.Click

Me.AxWebBrowser1.Navigate2(" www.go ogle.com")

End Sub

我希望这有点帮助吗?


Cor

VBSome < no*@home.net>
VBSome

I do not know what you do wrong, however here a very simple way to use the
AXwebbrowser (the same as in VB6).

Open a new windows application project

In the toolbox rightclick and select add/Remove items

In the customize toolbox select Com and in that Microsoft Webbrowser

When that is in the toolbox drag it to your form
Drag also a button to your form.

Then this code and you have a mini Webbrowser.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.AxWebBrowser1.Navigate2("www.google.com")
End Sub
I hope this helps a little bit?

Cor
"VBSome" <no*@home.net>
据我所知,没有原生VB.NET相当于VB6
Web浏览器控件。有些事情我可以用HTML明智地玩,但
没有做我真正需要做的事情(最终是以DOM&
编程点击DOM中的元素)。

我正在尝试通过使用网络浏览器控制来通过com互操作来重建我在dotnet中使用VB6完成的一些工作。救命!它的行为与我以前不同,我不知道从哪里开始......

我想要完成的最重要事件之一就是
DocumentComplete事件。每次在
网络浏览器中加载框架或iFrame中的文档时,DocumentComplete都会触发(或至少应该触发)。

我需要做什么(我在VB6中完美地工作)我需要等待一定数量的docComplete事件,然后再继续使用剩下的代码。在VB6中,这没有问题。我编写的导航方法
只是查看我声明的每次被doComplete触发的属性。 VB6的愚蠢很可爱,只要属性不是X(同时),我的方法实际上会停止。

这个相同的逻辑在dotnet中不起作用。我有一个导航方法,在类级别我声明了一个withevents变量。如果我在我的导航方法中放置了一个Do ... While
(封装属性值的检查),它将永远不会释放,并且docComplete事件永远不会触发。如果我采取行动......
在外出时,那么doComplete会发射,但直到我的导航方法已经完成...

显然我是一个dotnetnewbie .. ..我做错了什么?
As far as I understand there is no native VB.NET equivalent of the VB6
Web browser control. There are some things I can play with HTML wise, but
none do what I really need to do (which is ultimately walk the DOM &
programatically click on elements in the DOM).

I am trying to rebuild some of the stuff I''ve done in VB6 in dotnet by
using the web browser control thru the com interop. HELP! It behaves
different then I am used to and I am not sure where to go from here...

One of the most important events in what I am trying to accomplish is the
DocumentComplete event. The DocumentComplete fires (or at least should
fire) every time a document in a frame or an iFrame is done loading in the
web browser.

For what I need to do (and I have this working perfectly in VB6) I need to
wait an X amount of docComplete events before continuing with the rest of
the code. In VB6 this is no problem. The method I write that navigates
simply looks at a property I declared that gets upped by one every time
the doComplete fires. VB6 is lovely in its stupidity that my method will
actually halt for as long as the property is not X (Do while).

This same logic does not work in dotnet. I have a navigate method and at
the class level I declare a withevents variable. If I put a Do... While
(encapsulating the check for the property value) in my navigate method, it
never releases and the docComplete event never fires. If I take the Do...
While out, then the doComplete fires but not until my navigate method is
already finished...

Obviously I am a dotnetnewbie.... What am I doing wrong??





" VBSome" < no*@home.net>在消息中写道

news:kh ****************** @ newssvr11.news.prodigy.c om ...

"VBSome" <no*@home.net> wrote in message
news:kh******************@newssvr11.news.prodigy.c om...
这个逻辑在dotnet中不起作用。我有一个导航方法,在类级别我声明了一个withevents变量。如果我在我的导航方法中放置了一个Do ... While
(封装属性值的检查),它将永远不会释放,并且docComplete事件永远不会触发。如果我采取行动......
在外出时,doComplete会触发,但直到我的导航方法已经完成...
This same logic does not work in dotnet. I have a navigate method and at
the class level I declare a withevents variable. If I put a Do... While
(encapsulating the check for the property value) in my navigate method, it
never releases and the docComplete event never fires. If I take the Do...
While out, then the doComplete fires but not until my navigate method is
already finished...




尝试重做代码以避免轮询Do ... While。对于

示例,让DocComplete事件调用一个增加

计数器的例程,然后在计数器达到正确值时执行操作

(虽然我不得不说这种技术听起来很脆弱。)


它也值得看看计时器。计时器不会阻止你的

应用程序中的任何内容,所以如果你不能避免轮询,请让计时器执行它。


Tim

..NET的利弊
http://www.itwriting.com/phorum/list.php?f=6


Cor:

不,对不起,这没有用。我知道如何创建Web浏览器。我实际上创建了一个应用程序(或者更确切地说是重新创建)来遍历DOM

,然后可以执行操作(例如点击链接,填写这个

textbox)基于它呈现的HTML元素。不幸的是,我已经知道你所谈论的所有东西了。


蒂姆:

这就是它的确切位置失败。如果我不能在方法内回应它,我如何回应

方法之外的事件?就像我说的那样,VB6在这方面是非常愚蠢的。我猜计时器有一些优点。我应该试试
。至于它是脆弱的....有时你别无选择。


基本上我正在做的是写一个脚本语言。这可以直观地通过网站浏览
。有时你必须执行一个只能在先发生其他事情后执行的行动。我没有代码

点击按钮(或尝试)如果尚未加载该按钮。出于原因

起初可能并不明显,我们选择了计算docCompletes

而不是试图继续控制直到成功或超时。


我会尝试一个基于计时器的模型,感谢您的回复,如果有人要添加任何东西,请告诉我。
Cor:
No, sorry, that doesn''t help. I know how to create a web browser. I am
actually creating an application (or rather recreating) that walks the DOM
and then can perform actions (such as "click on link", "fill in this
textbox") based on the HTML Element it is presented with. I, unfortunately,
already know all the stuff you talk about.

Tim:
That''s exactly where it fails. How do I respond to an event outside the
method if I can''t respond to it inside the method? Like I said, VB6 was
brilliantly stupid in that respect. I guess timers have some merit. I
should try that. As for it being "frail".... Sometimes you have no choice.

Basically what I am doing is writing a "script language" that can visually
navigate through web sites. Sometimes you have to perform an action that can
only be executed after something else happens first. I can''t have the code
click on a button (or try) if that button is not loaded yet. For reasons
that might not be obvious at first we have opted to count docCompletes
rather then just trying to keep hitting a control until succes or time out.

I will try a timer based model, thanks for the responses and if anyone has
anything to add, let me know.


这篇关于Internet Explorer对象...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆