Make mouse click
Posted: Sat Aug 23, 2008 4:59 pm
Does anyone know how to make it so when you click the mouse its like the mouse is constantly clicking like at 20 clicks a second or something.
Visit remnantmods.com for more information
http://www.halomods.info/
Code: Select all
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;
Code: Select all
public void DoMouseClick()
{
//Call the imported function with the cursor's current position
int X = Cursor.Position.X;
int Y = Cursor.Position.Y;
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
}
Put this at the top of your code file.mr_penguin wrote:thanks
Wait, is this C# or C++ because dllimports keeps giving me an error:
Error 1 The type or namespace name 'DllImport' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Logan\Local Settings\Application Data\Temporary Projects\Auto Click\Form1.cs 21 10 Auto Click
Code: Select all
using System.Runtime.InteropServices;
I copy pasted it from a website and didn't check up with MSDN. Didn't even notice that the params were all long.kornman00 wrote:I would suggest you sharpen up your interop skills, mouse_event's parameters are all uint based. long is a no-no, especially for the last parameter which is a pointer which in mouse_event's case is 32bit.