使用 VB.NET 以编程方式单击和移动鼠标

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1255364/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 14:20:08  来源:igfitidea点击:

Programmatically click and move mouse with VB.NET

vb.netclickmousemove

提问by jmasterx

I want to build a program in VB .net that will allow me to control my pc with my laptop. The only question I really have is, how can I programmatically click without using some kind of click event, say if I want to click the start orb and my mouse is at that exact location, I'd like a sub or something that will click on it. Right now I only know how to click within the form.

我想在 VB .net 中构建一个程序,它可以让我用我的笔记本电脑控制我的电脑。我真正有的唯一问题是,如何在不使用某种点击事件的情况下以编程方式点击,比如说如果我想点击开始球并且我的鼠标在那个确切的位置,我想要一个子或会点击的东西在上面。现在我只知道如何在表单中单击。

Thanks

谢谢

采纳答案by jmasterx

回答by Nick

You can set the Cursor position with the property Cursor.Position.

您可以使用属性设置光标位置Cursor.Position

You will need to P/Invoke mouse_eventin user32.dllin order to simulate the mouse click.

您需要在 user32.dllP/Invokemouse_event以模拟鼠标单击。

Sample code in C# is here: http://www.gamedev.net/community/forums/topic.asp?topic_id=321029

C# 中的示例代码在这里:http: //www.gamedev.net/community/forums/topic.asp?topic_id=321029