如何右键单击HTML HTML元素? [英] How can I right click on HTML HTML Element?

查看:102
本文介绍了如何右键单击HTML HTML元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用VB 6.0进行HTML编程时遇到一个问题.我创建了一个自动化程序,以使用Visual Basic 6.0在Internet上填写Web表单.
例如下面的代码观察者.

步骤1:创建一个标准EXE项目.

步骤2:添加对"Microsoft HTML对象库"的引用-您可以从\ windows \ system32 \ mshtml.tlb
添加此引用
步骤3:添加对"Microsoft Internet Controls"的引用-您可以从\ windows \ system32 \ ieframe.dll中添加它.
在form1中复制并粘贴以下代码.

Hi,

I am facing one issue with HTML programming with VB 6.0. I have created one automate program to fill a web form on the internet with Visual Basic 6.0.
For example observer below code.

Step 1: Create one Standard EXE project.

Step 2: Add reference to "Microsoft HTML Object Library" - You can add this from \windows\system32\mshtml.tlb

Step 3: Add reference to "Microsoft Internet Controls" - You can add this from \windows\system32\ieframe.dll.

Copy and Paste Below code in form1.

<pre><br />
Private Sub Form_Load()<br />
<br />
Dim IE As SHDocVw.InternetExplorer<br />
Set IE = Nothing<br />
Set IE = CreateObject("InternetExplorer.Application")<br />
<br />
IE.Navigate "www.google.com"<br />
<br />
Do While IE.Busy<br />
    DoEvents<br />
    DoEvents<br />
Loop<br />
<br />
IE.Visible = True<br />
<br />
Dim HtmEle As HTMLHtmlElement<br />
DoEvents<br />
DoEvents<br />
IE.Document.getElementById("q").Value = "text"<br />
DoEvents<br />
DoEvents<br />
<br />
Set HtmEle = IE.Document.getElementById("btng")<br />
If Not HtmEle Is Nothing Then<br />
    MsgBox "HtmEle Object set." & vbCrLf & "Now it will click on Google Search button."<br />
    HtmEle.Click<br />
End If<br />
<br />
End<br />
<br />
End Sub<br />
</pre>



现在,我不想在Google Search按钮上单击鼠标,而是在该按钮上单击鼠标右键.我试图用mouse_event API做到这一点,它将解决我的问题.但是,当我调整IE大小或移动IE时,它会失败.我想我需要该htmele的X,Y坐标.

我有什么办法可以右键单击该htmele?
如果我可以在屏幕上得到htmEle的X,Y坐标,那也将非常有帮助.

预先感谢.



Now instead of doing this click on Google Search button I want to do Right Click on that button. I tried to do it with mouse_event API it would solve my issue. But it gets failed when I resize the IE or move IE. I think I will require X,Y co-ordinate of that htmele.

Is there any way from that I can do right click on that htmele?
If I can get X,Y co-ordinate of htmEle in screen that would be also very helpful.

Thanks in advance.

推荐答案

创建ContextMenu对象,并将其附加到要具有上下文菜单的控件. -上下文菜单是右键单击菜单..


例如:> http://www.elguille.info/NET/csharp/beta2/notifyiconCS.ht [^ ]
Create a ContextMenu object and attach it to the control you want to have a context menu. - a context menu is a right click menu..


example:http://www.elguille.info/NET/csharp/beta2/notifyiconCS.ht[^]


这篇关于如何右键单击HTML HTML元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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