Have you included the following line?
[DllImport("user32.dll")]
static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData,
UIntPtr dwExtraInfo);
This will import the function mouse_event
from the user32
dll, which is what you are trying to use within your program. Currently your program does not know about this method within the DLL untill you specify wher it comes from.
The website PInvoke.net user32 Mouse Event is quite handy for the basics on this sort of thing.
The answer to Directing mouse events [DllImport(“user32.dll”)] click, double click will be of great help to your understanding as well.
The flags
are what commands you want to send into the mouse_input
function, in that example you can see that he is sending both mouse down
and mouse up
in the same line, this is fine because the mouse_event
function will split those flags up and execute them consecutively.
Also note that this method has been superseded by the SendInput
command, a good example of SendInput
and SetMousePos
can be found At this Blog