[C#]mouse_event and SetCursorPos
Lets start with the tuturial.
Since we're going to use imports from user32.dll, we'll need to let MSVC# know we want to be able to import functions from Dll's.
So add the following under the other 'using' statements:
Now that is done we can do some defining and importing, the following code goes in 'public partial class Form1 : Form'
Now that you have those declared and the functions imported add a button to your form, name it whatever you like.
Double click it to have the OnClick event generated, and put the following code in it:
The above code will generate a random number between 0 and 800 for the X coordinate, and between 0 and 600 for the Y coordinate, then it sets the cursor's position to it and makes the user click there.
Now if you'd want to right click you'd use:
Have fun 
Credits:
Unkn0wn_h4cker
Attached is the sample project
Since we're going to use imports from user32.dll, we'll need to let MSVC# know we want to be able to import functions from Dll's.
So add the following under the other 'using' statements:
Code:
using System.Runtime.InteropServices;
Code:
private const int MOUSEEVENTF_LEFTDOWN = 0x2;
private const int MOUSEEVENTF_LEFTUP = 0x4;
private const int MOUSEEVENTF_RIGHTDOWN = 0x8;
private const int MOUSEEVENTF_RIGHTUP = 0x10;
[DllImport("USER32.dll", CallingConvention=CallingConvention.StdCall)]
static extern void mouse_event(int dwFlags, int dx , int dy, int cButtons, int dwExtraInfo);
[DllImport("USER32.dll", CallingConvention = CallingConvention.StdCall)]
static extern void SetCursorPos(int X, int Y);
Double click it to have the OnClick event generated, and put the following code in it:
Code:
Random myRand = new Random();
int CursorX = myRand.Next(800);
int CursorY = myRand.Next(600);
SetCursorPos(CursorX, CursorY);
mouse_event(MOUSEEVENTF_LEFTDOWN, CursorX, CursorY, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, CursorX, CursorY, 0, 0);
Now if you'd want to right click you'd use:
Code:
mouse_event(MOUSEEVENTF_RIGHTDOWN, CursorX, CursorY, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTUP, CursorX, CursorY, 0, 0);

Credits:
Unkn0wn_h4cker
Attached is the sample project
CursorStuff.rar
