using System.Drawing; using System.Windows.Forms; using CC_Functions.W32.Native; namespace CC_Functions.W32 { /// /// Functions for manipulating the mouse /// public static class Mouse { private const int MouseEventFLeftDown = 0x02; private const int MouseEventFLeftUp = 0x04; private const int MouseEventFRightDown = 0x08; private const int MouseEventFRightUp = 0x10; /// /// Emulates a click at the cursors position /// /// Set to true to perform right-clicks instead of left-clicks public static void Click(bool right = false) => Click(Cursor.Position, right); /// /// Emulates a click at the specified position /// /// The position to perform the click at /// Set to true to perform right-clicks instead of left-clicks public static void Click(Point location, bool right = false) => user32.mouse_event( (uint) (right ? MouseEventFRightDown | MouseEventFRightUp : MouseEventFLeftDown | MouseEventFLeftUp), (uint) location.X, (uint) location.Y, 0, 0); } }