Code:
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern short GetAsyncKeyState(int vkey);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern void mouse_event(UInt32 dwFlags, UInt32 dx,UInt32 dy,UInt32 dwData,IntPtr dwExtraInfo);
bool Active = false;
private void timer1_Tick(object sender, EventArgs e)
{
if (Convert.ToBoolean(GetAsyncKeyState(0x02)))
Active = true;
if (Convert.ToBoolean(GetAsyncKeyState(0x01)) && Active == true)
{
mouse_event(0x2, 0, 0, 0, IntPtr.Zero);
mouse_event(0x4, 0, 0, 0, IntPtr.Zero);
if (Convert.ToBoolean(GetAsyncKeyState(0x02)))
{
Active = false;
}
}
}