How to simulate mouse clicks?

独自空忆成欢 提交于 2019-12-22 13:51:20

问题


I was wondering how to create a sort of auto clicker using 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 :)


回答1:


See this discussion on social.msdn: Simulate a mouse click in a program.

Uses winapi: SetCursorPos, GetCursorPos and mouse_event.




回答2:


I believe you need to P/Invoke into Windows to accomplish this.

Have a look at the SendInput function.




回答3:


If you are using automate the program,that program have some tabindex in order to relevant control.then you can use;

SendKeys.Send("{TAB}");
SendKeys.Send("{ENTER}");

it is more accurate on desktop application



来源:https://stackoverflow.com/questions/13532604/how-to-simulate-mouse-clicks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!