From f6d8b2c98870a4611ff089fb414865e87e21e1ad Mon Sep 17 00:00:00 2001 From: "Valeriano A.R" Date: Sat, 9 Apr 2022 16:32:34 +0200 Subject: [PATCH] Remove duplicated Mouse class --- VAR.Toolbox/Code/Bots/Mouse.cs | 169 ------------------ .../ScreenAutomation/FrmScreenAutomation.cs | 2 - VAR.Toolbox/VAR.Toolbox.csproj | 1 - 3 files changed, 172 deletions(-) delete mode 100644 VAR.Toolbox/Code/Bots/Mouse.cs diff --git a/VAR.Toolbox/Code/Bots/Mouse.cs b/VAR.Toolbox/Code/Bots/Mouse.cs deleted file mode 100644 index 0cbe672..0000000 --- a/VAR.Toolbox/Code/Bots/Mouse.cs +++ /dev/null @@ -1,169 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -// ReSharper disable InconsistentNaming - -namespace VAR.ScreenAutomation.Code -{ - public static class Mouse - { - public enum MouseButtons - { - Left, - Middle, - Right - } - - public static void SetButton(MouseButtons button, bool down) - { - INPUT input = new INPUT - { - Type = INPUT_MOUSE - }; - input.Data.Mouse.X = 0; - input.Data.Mouse.Y = 0; - if (button == MouseButtons.Left) - { - input.Data.Mouse.Flags = down ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP; - } - - if (button == MouseButtons.Middle) - { - input.Data.Mouse.Flags = down ? MOUSEEVENTF_MIDDLEDOWN : MOUSEEVENTF_MIDDLEUP; - } - - if (button == MouseButtons.Right) - { - input.Data.Mouse.Flags = down ? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_RIGHTUP; - } - - INPUT[] inputs = new INPUT[] { input }; - if (SendInput(1, inputs, Marshal.SizeOf(typeof(INPUT))) == 0) - throw new Exception(); - } - - public static void Click(MouseButtons button) - { - SetButton(button, true); - System.Threading.Thread.Sleep(500); - SetButton(button, false); - } - - public static void GetPosition(out UInt32 x, out UInt32 y) - { - GetCursorPos(out POINT lpPoint); - x = lpPoint.X; - y = lpPoint.Y; - } - - public static void SetPosition(UInt32 x, UInt32 y) - { - SetCursorPos(x, y); - } - - [StructLayout(LayoutKind.Sequential)] - public struct INPUT - { - public uint Type; - public MOUSEKEYBDHARDWAREINPUT Data; - } - - public const int INPUT_MOUSE = 0; - public const int INPUT_KEYBOARD = 1; - public const int INPUT_HARDWARE = 2; - - /// - /// http://social.msdn.microsoft.com/Forums/en/csharplanguage/thread/f0e82d6e-4999-4d22-b3d3-32b25f61fb2a - /// - [StructLayout(LayoutKind.Explicit)] - public struct MOUSEKEYBDHARDWAREINPUT - { - [FieldOffset(0)] public HARDWAREINPUT Hardware; - - [FieldOffset(0)] public KEYBDINPUT Keyboard; - - [FieldOffset(0)] public MOUSEINPUT Mouse; - } - - /// - /// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310(v=vs.85).aspx - /// - [StructLayout(LayoutKind.Sequential)] - public struct HARDWAREINPUT - { - public uint Msg; - public ushort ParamL; - public ushort ParamH; - } - - /// - /// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310(v=vs.85).aspx - /// - [StructLayout(LayoutKind.Sequential)] - public struct KEYBDINPUT - { - public ushort Vk; - public ushort Scan; - public uint Flags; - public uint Time; - public IntPtr ExtraInfo; - } - - /// - /// http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/2abc6be8-c593-4686-93d2-89785232dacd - /// https://msdn.microsoft.com/es-es/library/windows/desktop/ms646273%28v=vs.85%29.aspx - /// - [StructLayout(LayoutKind.Sequential)] - public struct MOUSEINPUT - { - public int X; - public int Y; - public uint MouseData; - public uint Flags; - public uint Time; - public IntPtr ExtraInfo; - } - - public const int MOUSEEVENTD_XBUTTON1 = 0x0001; - public const int MOUSEEVENTD_XBUTTON2 = 0x0002; - - public const uint MOUSEEVENTF_ABSOLUTE = 0x8000; - public const uint MOUSEEVENTF_HWHEEL = 0x01000; - public const uint MOUSEEVENTF_MOVE = 0x0001; - public const uint MOUSEEVENTF_MOVE_NOCOALESCE = 0x2000; - public const uint MOUSEEVENTF_LEFTDOWN = 0x0002; - public const uint MOUSEEVENTF_LEFTUP = 0x0004; - public const uint MOUSEEVENTF_RIGHTDOWN = 0x0008; - public const uint MOUSEEVENTF_RIGHTUP = 0x0010; - public const uint MOUSEEVENTF_MIDDLEDOWN = 0x0020; - public const uint MOUSEEVENTF_MIDDLEUP = 0x0040; - public const uint MOUSEEVENTF_VIRTUALDESK = 0x4000; - public const uint MOUSEEVENTF_WHEEL = 0x0800; - public const uint MOUSEEVENTF_XDOWN = 0x0080; - public const uint MOUSEEVENTF_XUP = 0x0100; - - [DllImport("User32.dll")] - public static extern int SendInput(int nInputs, INPUT[] pInputs, int cbSize); - - - /// - /// Struct representing a point. - /// - [StructLayout(LayoutKind.Sequential)] - public struct POINT - { - public UInt32 X; - public UInt32 Y; - } - - /// - /// Retrieves the cursor's position, in screen coordinates. - /// - /// See MSDN documentation for further information. - [DllImport("user32.dll")] - public static extern bool GetCursorPos(out POINT lpPoint); - - [DllImport("User32.dll")] - public static extern Boolean SetCursorPos(UInt32 x, UInt32 y); - } -} \ No newline at end of file diff --git a/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmScreenAutomation.cs b/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmScreenAutomation.cs index 0d414eb..d3ae91a 100644 --- a/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmScreenAutomation.cs +++ b/VAR.Toolbox/UI/Tools/ScreenAutomation/FrmScreenAutomation.cs @@ -3,12 +3,10 @@ using System.ComponentModel; using System.Drawing; using System.Linq; using System.Windows.Forms; -using VAR.ScreenAutomation.Code; using VAR.Toolbox.Code; using VAR.Toolbox.Code.Bots; using VAR.Toolbox.Code.Configuration; using VAR.Toolbox.Controls; -using Mouse = VAR.ScreenAutomation.Code.Mouse; // ReSharper disable LocalizableElement diff --git a/VAR.Toolbox/VAR.Toolbox.csproj b/VAR.Toolbox/VAR.Toolbox.csproj index 71f9fc7..552307f 100644 --- a/VAR.Toolbox/VAR.Toolbox.csproj +++ b/VAR.Toolbox/VAR.Toolbox.csproj @@ -78,7 +78,6 @@ -