[StructLayout(LayoutKind.Explicit, Pack = 1, Size = 28)]
public struct INPUT
{
[FieldOffset(0)]
public INPUTTYPE dwType;
[FieldOffset(4)]
public MOUSEINPUT mi;
[FieldOffset(4)]
public KEYBOARDINPUT ki;
[FieldOffset(4)]
public HARDWAREINPUT hi;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct MOUSEINPUT
{
public Int32 dx;
public Int32 dy;
public Int32 mouseData;
public MOUSEFLAG dwFlags;
public Int32 time;
public IntPtr dwExtraInfo;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct KEYBOARDINPUT
{
public Int16 wVk;
public Int16 wScan;
public KEYBOARDFLAG dwFlags;
public Int32 time;
public IntPtr dwExtraInfo;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct HARDWAREINPUT
{
public Int32 uMsg;
public Int16 wParamL;
public Int16 wParamH;
}
public enum INPUTTYPE : int
{
Mouse = 0,
Keyboard = 1,
Hardware = 2
}
[Flags()]
public enum MOUSEFLAG : int
{
LEFTDOWN = 0x2,
LEFTUP = 0x4,
}
[Flags()]
public enum KEYBOARDFLAG : int
{
EXTENDEDKEY = 1,
KEYUP = 2,
UNICODE = 4,
SCANCODE = 8
}
static public void LeftDown()
{
INPUT leftdown = new INPUT();