Programmatically Click mouse on specefic location
-
I m trying to click mouse automatically using code in some specific location for this i m using following code but its not working
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);public const int MOUSEEVENTF_LEFTDOWN = 0x02;
public const int MOUSEEVENTF_LEFTUP = 0x04;
public const int MOUSEEVENTF_RIGHTDOWN = 0x08;
public const int MOUSEEVENTF_RIGHTUP = 0x10;public void MouseClick()
{
int x = 100;
int y = 100;mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
}Plz Help me To move cursor i m using Cursor.Position = new Point((int)10, (int)10); thats working fine Plz help
-
I m trying to click mouse automatically using code in some specific location for this i m using following code but its not working
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);public const int MOUSEEVENTF_LEFTDOWN = 0x02;
public const int MOUSEEVENTF_LEFTUP = 0x04;
public const int MOUSEEVENTF_RIGHTDOWN = 0x08;
public const int MOUSEEVENTF_RIGHTUP = 0x10;public void MouseClick()
{
int x = 100;
int y = 100;mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
}Plz Help me To move cursor i m using Cursor.Position = new Point((int)10, (int)10); thats working fine Plz help
OK the Problem IS SOlved
-
I m trying to click mouse automatically using code in some specific location for this i m using following code but its not working
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);public const int MOUSEEVENTF_LEFTDOWN = 0x02;
public const int MOUSEEVENTF_LEFTUP = 0x04;
public const int MOUSEEVENTF_RIGHTDOWN = 0x08;
public const int MOUSEEVENTF_RIGHTUP = 0x10;public void MouseClick()
{
int x = 100;
int y = 100;mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
}Plz Help me To move cursor i m using Cursor.Position = new Point((int)10, (int)10); thats working fine Plz help
Hi, I'm using the following user32 functions: - SetCursorPos() to move the mouse - SendInput() to give a MOUSEEVENTF_LEFTDOWN and MOUSEEVENTF_LEFTUP IIRC the x,y parameters of mouse_event describe a relative mouse movement, so I keep them at zero. Here are my P/Invoke prototypes:
\[DllImport("user32.dll", CallingConvention=CallingConvention.StdCall, SetLastError=true)\] public static extern IntPtr SendInput(int count, ref INPUT2 input, int size); \[DllImport("user32.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)\] public static extern IntPtr SetCursorPos(int x, int y); public struct MOUSEINPUT { public int dx; public int dy; public int mouseData; public int dwFlags; public int time; public IntPtr dwExtraInfo; } public struct INPUT2 { public uint type1; public MOUSEINPUT mi1; public uint type2; public MOUSEINPUT mi2; }
:)
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
OK the Problem IS SOlved
shaina2231 wrote:
OK the Problem IS SOlved
And how exactly did you solve the problem? I'm interested because I'm working on same thing. Lukas