2020-05-25 19:32:53 +02:00
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using CC_Functions.W32.Native;
|
2020-03-11 18:40:58 +01:00
|
|
|
|
|
|
|
|
|
namespace CC_Functions.W32
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2020-03-13 19:19:55 +01:00
|
|
|
|
/// Functions for manipulating the mouse
|
2020-03-11 18:40:58 +01:00
|
|
|
|
/// </summary>
|
|
|
|
|
public static class Mouse
|
|
|
|
|
{
|
|
|
|
|
private const int MouseEventFLeftDown = 0x02;
|
|
|
|
|
private const int MouseEventFLeftUp = 0x04;
|
|
|
|
|
private const int MouseEventFRightDown = 0x08;
|
|
|
|
|
private const int MouseEventFRightUp = 0x10;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-03-13 19:19:55 +01:00
|
|
|
|
/// Emulates a click at the cursors position
|
2020-03-11 18:40:58 +01:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="right">Set to true to perform right-clicks instead of left-clicks</param>
|
|
|
|
|
public static void Click(bool right = false) => Click(Cursor.Position, right);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-03-13 19:19:55 +01:00
|
|
|
|
/// Emulates a click at the specified position
|
2020-03-11 18:40:58 +01:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="location">The position to perform the click at</param>
|
|
|
|
|
/// <param name="right">Set to true to perform right-clicks instead of left-clicks</param>
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|