private static void MoveMouse(int x, int y) { NM.INPUT[] MouseEvent = new NM.INPUT[1]; MouseEvent[0].type = NM.INPUT_TYPE.INPUT_MOUSE; MouseEvent[0].U.mi = CreateMouseInput(x, y, 0, 0, NM.MOUSEEVENTF.ABSOLUTE | NM.MOUSEEVENTF.MOVE); NM.SendInput((uint)MouseEvent.Length, MouseEvent, Marshal.SizeOf(MouseEvent[0].GetType())); }
/// <summary> /// Presses and releases the left alt key /// </summary> public static void SendAltKey() { NM.INPUT[] inputEvent = new NM.INPUT[2]; inputEvent[0].type = NM.INPUT_TYPE.INPUT_KEYBOARD; inputEvent[0].U.ki = CreateKeyboardInput(NM.VirtualKeyShort.LMENU, NM.ScanCodeShort.LMENU, NM.KEYEVENTF.NONE, 0, UIntPtr.Zero); inputEvent[1].type = NM.INPUT_TYPE.INPUT_KEYBOARD; inputEvent[1].U.ki = CreateKeyboardInput(NM.VirtualKeyShort.LMENU, NM.ScanCodeShort.LMENU, NM.KEYEVENTF.KEYUP, 0, UIntPtr.Zero); NM.SendInput((uint)inputEvent.Length, inputEvent, NM.INPUT.Size); }