Update Program.cs
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
46
Program.cs
46
Program.cs
@@ -8,9 +8,6 @@ namespace MouseSimulator
|
|||||||
public class MouseSimulator
|
public class MouseSimulator
|
||||||
{
|
{
|
||||||
// Импорт необходимых функций из user32.dll
|
// Импорт необходимых функций из user32.dll
|
||||||
//[DllImport("user32.dll")]
|
|
||||||
//private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);
|
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
private static extern bool GetCursorPos(out POINT lpPoint);
|
private static extern bool GetCursorPos(out POINT lpPoint);
|
||||||
|
|
||||||
@@ -24,20 +21,6 @@ namespace MouseSimulator
|
|||||||
public int Y;
|
public int Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Константы для mouse_event
|
|
||||||
/*
|
|
||||||
private const uint MOUSEEVENTF_LEFTDOWN = 0x0002;
|
|
||||||
private const uint MOUSEEVENTF_LEFTUP = 0x0004;
|
|
||||||
private const uint MOUSEEVENTF_RIGHTDOWN = 0x0008;
|
|
||||||
private const uint MOUSEEVENTF_RIGHTUP = 0x0010;
|
|
||||||
private const uint MOUSEEVENTF_MIDDLEDOWN = 0x0020;
|
|
||||||
private const uint MOUSEEVENTF_MIDDLEUP = 0x0040;
|
|
||||||
private const uint MOUSEEVENTF_WHEEL = 0x0800;
|
|
||||||
private const uint MOUSEEVENTF_HWHEEL = 0x01000;
|
|
||||||
private const uint MOUSEEVENTF_MOVE = 0x0001;
|
|
||||||
private const uint MOUSEEVENTF_ABSOLUTE = 0x8000;
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Перемещение курсора
|
// Перемещение курсора
|
||||||
public static void MoveTo(int x, int y)
|
public static void MoveTo(int x, int y)
|
||||||
{
|
{
|
||||||
@@ -47,37 +30,10 @@ namespace MouseSimulator
|
|||||||
// Поулчение позиции курсора
|
// Поулчение позиции курсора
|
||||||
public static POINT GetPosition()
|
public static POINT GetPosition()
|
||||||
{
|
{
|
||||||
POINT point;
|
if (GetCursorPos(out POINT point))
|
||||||
if (GetCursorPos(out point))
|
|
||||||
return point;
|
return point;
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// Левый клик
|
|
||||||
public static void LeftClick()
|
|
||||||
{
|
|
||||||
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Правый клик
|
|
||||||
public static void RightClick()
|
|
||||||
{
|
|
||||||
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Прокрутка колеса
|
|
||||||
public static void MouseWheel(int delta)
|
|
||||||
{
|
|
||||||
mouse_event(MOUSEEVENTF_WHEEL, 0, 0, (uint)delta, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Горизонтальная прокрутка
|
|
||||||
public static void MouseHWheel(int delta)
|
|
||||||
{
|
|
||||||
mouse_event(MOUSEEVENTF_HWHEEL, 0, 0, (uint)delta, 0);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class Program
|
internal class Program
|
||||||
|
|||||||
Reference in New Issue
Block a user