控制鼠标位置并点击SECOND监视器 [英] Control mouse position and clicks on SECOND monitor

查看:109
本文介绍了控制鼠标位置并点击SECOND监视器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要控制鼠标位置,然后在第二台显示器上的窗口中的按钮上单击鼠标。我已经尝试了几种控制鼠标位置和点击的方法,但还没有找到将鼠标发送到主监视器以外的任何监视器的方法。我正在使用Visual Basic(.NET 2015)。



我尝试过:



Private Sub OneClick_Click(发送者为对象,e为EventArgs)处理OneClick.Click



Dim Monitor As Object

Monitor = Screen.AllScreens(1).WorkingArea



SetCursorPos(299,299)

mouse_event(M_LEFTDOWN,0,0,0) ,0)

mouse_event(M_LEFTUP,0,0,0,0)



结束Sub

I need to control mouse position and click the mouse on buttons in a window on a 2nd monitor. I have tried several methods of controlling mouse position and clicking, but have not found a way to send the mouse to any monitor other than the primary monitor. I'm working with Visual Basic (.NET 2015).

What I have tried:

Private Sub OneClick_Click(sender As Object, e As EventArgs) Handles OneClick.Click

Dim Monitor As Object
Monitor = Screen.AllScreens(1).WorkingArea

SetCursorPos(299, 299)
mouse_event(M_LEFTDOWN, 0, 0, 0, 0)
mouse_event(M_LEFTUP, 0, 0, 0, 0)

End Sub

推荐答案

您使用的监视器没有区别,因为您将其用作虚拟屏幕的一部分。这就是为什么你得到不同的 WorkingArea 对象。一个监视器是另一个监视器的延续。如果您在两台显示器显示相同图像的情况下使用该模式,由于明显的原因,它仍然没有区别。所以,点击你想要的地方。



如何模拟活动?方法如下: SendInput功能(Windows)



要在.NET中使用,请使用P / Invoke。这一切都已经为您完成了: http://www.pinvoke.net/default.aspx/user32.sendinput



-SA
There is no difference what monitor you use, because you use it as a part of a virtual screen. That's why you get different WorkingArea objects. One monitor is continuation of another one. And in case you are using the mode when two monitors show identical image, it still makes no difference, by obvious reasons. So, click where you want it.

How to simulate the event? Here is how: SendInput function (Windows).

To do in in .NET, you use P/Invoke. It's all already done for you: http://www.pinvoke.net/default.aspx/user32.sendinput.

—SA


这篇关于控制鼠标位置并点击SECOND监视器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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