问题
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