如何在vb.net中模拟鼠标点击

发布于 2024-12-02 00:49:17 字数 107 浏览 0 评论 0原文

我希望能够在 vb.net 中的 WebBroswer 上模拟鼠标点击(即使程序不在顶部,它也会在后台运行)我该怎么做?我希望它在网络浏览器中每秒单击一个按钮。有什么想法吗?

提前致谢

I wants to be able to simulate mouse clicks on a WebBroswer in vb.net (even when the program in not on top, it will run in the background) How would I do this? I want it to click on a button every one second in the webBrowser. Any ideas?

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

下壹個目標 2024-12-09 00:49:17

警告:这是使用 Excel 4 宏的可怕黑客行为。它实际上是用 VBScript 编写的,但如果我没记错的话,在 .NET 中的语法即使不完全相同,也是相似的。当然,你需要安装Excel。

Set Excel = WScript.CreateObject("Excel.Application")

' Where on the screen do you want to click?
i = "111"
j = "222"

Excel.ExecuteExcel4Macro ( _
    "CALL(""user32"",""SetCursorPos"",""JJJ""," & i & "," & j & ")")

WScript.Sleep 100
Excel.Quit
Set Excel = Nothing

期待更多优雅的答案!

Warning: This is an awful hack using an Excel 4 macro. It's actually written in VBScript, but if I'm not mistaken the syntax is similar if not identical in .NET. Of course, you need Excel to be installed.

Set Excel = WScript.CreateObject("Excel.Application")

' Where on the screen do you want to click?
i = "111"
j = "222"

Excel.ExecuteExcel4Macro ( _
    "CALL(""user32"",""SetCursorPos"",""JJJ""," & i & "," & j & ")")

WScript.Sleep 100
Excel.Quit
Set Excel = Nothing

Looking forward to more elegant answers!

绿萝 2024-12-09 00:49:17

您的操作数量有限,点击后才有效。使用计时器,并在每个计时器滴答时随机选择一个操作,并按顺序编号。

you will have a limited number of actions, that are valid after clicking. Use a timer and at each timer-tick select one of the actions randomly, numbering them sequentially.

卖梦商人 2024-12-09 00:49:17

在Excel.Quit....之前

执行以下操作:

WScript.Sleep(100)

以下就像模拟鼠标左键单击:
进行 IE 焦点或应用程序焦点:

'objIE.document.focus()
'myShell.sendkeys ("{enter}")

Before you Excel.Quit....

do the following:

WScript.Sleep(100)

The following is like simulation of mouse left click:
do a IE focus OR app focus:

'objIE.document.focus()
'myShell.sendkeys ("{enter}")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文