How do I trigger a mouse click?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello!

I'm trying to generate a VB.NET code to trigger/make a mouse click. Can someone write me a sample code to do that? It'd also help me if you knew how to trigger a right mouse button click. Thank you!
 
This is from
http://groups.google.de/groups?hl=d...-8&selm=u5dQvbS8BHA.2548%40tkmsftngp07&rnum=2 :


private const UInt32 MOUSEEVENTF_LEFTDOWN = 0x0002;
private const UInt32 MOUSEEVENTF_LEFTUP = 0x0004;

[DllImport("user32.dll")]
private static extern void mouse_event(
UInt32 dwFlags, // motion and click options
UInt32 dx, // horizontal position or change
UInt32 dy, // vertical position or change
UInt32 dwData, // wheel movement
IntPtr dwExtraInfo // application-defined information
);

public static void SendClick(Point location)
{
Cursor.Position = location;
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, new System.IntPtr());
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, new System.IntPtr());
}


Regards


Kingherc said:
Hello!

I'm trying to generate a VB.NET code to trigger/make a mouse click. Can
someone write me a sample code to do that? It'd also help me if you knew how
to trigger a right mouse button click. Thank you!
 
Back
Top