vb.net 如何模拟鼠标点击?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13532604/
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
How to simulate mouse clicks?
提问by user1298923
I was wondering how to create a sort of auto clicker using VB.NET.
我想知道如何使用 VB.NET 创建一种自动点击器。
I would basicly have the click coordinates pre-defined and the clicks, which would have to be separated by delays I guess since I want more than one to happen periodically, would happen outside of the application window (I read this envolves extra system hooks?).
我基本上会预先定义点击坐标和点击,我想这些点击必须被延迟分开,因为我希望定期发生不止一个,会发生在应用程序窗口之外(我读到这涉及额外的系统挂钩? )。
The only code I have been able to find is related to clicks on the application window, which is not what I am looking for.
我能找到的唯一代码与应用程序窗口上的点击有关,这不是我要找的。
In short:I want to click a button on the app window, which would initiate a number of clicks on certain pre-defined screen coordinates.
简而言之:我想单击应用程序窗口上的一个按钮,这将启动对某些预定义屏幕坐标的多次单击。
Thanks in advance :)
提前致谢 :)
采纳答案by Neolisk
See this discussion on social.msdn: Simulate a mouse click in a program.
请参阅 social.msdn 上的此讨论:在程序中模拟鼠标单击。
Uses winapi: SetCursorPos, GetCursorPosand mouse_event.
使用 winapi: SetCursorPos,GetCursorPos和mouse_event.
回答by Elshan
If you are using automate the program,that program have some tabindex in order to relevant control.then you can use;
如果您使用的是自动化程序,该程序有一些 tabindex 以便进行相关控制。那么您可以使用;
SendKeys.Send("{TAB}");
SendKeys.Send("{ENTER}");
it is more accurate on desktop application
在桌面应用程序上更准确

