VidyaGyan
Auto Click Mouse C# Code
Auto Click, Auto Move, Auto DoubleClick, Auto Right Click Mouse in C# .Net
//Create Class MouseWork
using System;using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Runtime.InteropServices;
using System.Collections;
class MouseWork
{
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
[DllImport("user32")]
public static extern int SetCursorPos(int x, int y);
public void Click()
{
mouse_event(0x0002, 0, 0, 0, 0);/* left button down value=0x0002 */
mouse_event(0x0004, 0, 0, 0, 0);/* left button down value=0x0004 */
}public void Double_Click()
{
mouse_event(0x0002, 0, 0, 0, 0);/* left button down value=0x0002 */
mouse_event(0x0004, 0, 0, 0, 0);/* left button down value=0x0004 */
Thread.Sleep(100);
mouse_event(0x0002, 0, 0, 0, 0);/* left button down value=0x0002 */
mouse_event(0x0004, 0, 0, 0, 0);/* left button down value=0x0004 */
}public void Right_Click()
{
mouse_event(0x0008, 0, 0, 0, 0); /* right button down value=0x0008 */
mouse_event(0x0010, 0, 0, 0, 0); /* right button up value=0x0010 */
}public void Move_Cursor(int x, int y)
{
SetCursorPos(x, y); //move_Cursor
}
}
//Note:Add your NameSpace if needed
//Using MouseWork Class
MouseWork mouse = new MouseWork();
mouse.Move_Cursor(0,0);
mouse.Click();
------------------------------------------------------------------------------------------------------