Upload files

Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
2025-05-29 12:19:24 +07:00
parent 6555793575
commit 3a9785573e
6 changed files with 234 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
.vs
bin/
obj/
packages/
*.csproj.user

6
App.config Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>

53
MouseSimulator.csproj Normal file
View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2FB36A1D-BD2B-47D9-9699-4BD158A9048C}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>MouseSimulator</RootNamespace>
<AssemblyName>MouseSimulator</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

25
MouseSimulator.sln Normal file
View File

@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35931.197 d17.13
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MouseSimulator", "MouseSimulator.csproj", "{2FB36A1D-BD2B-47D9-9699-4BD158A9048C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2FB36A1D-BD2B-47D9-9699-4BD158A9048C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2FB36A1D-BD2B-47D9-9699-4BD158A9048C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2FB36A1D-BD2B-47D9-9699-4BD158A9048C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2FB36A1D-BD2B-47D9-9699-4BD158A9048C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1FE8367E-2F14-4F26-873F-D5093BAE851D}
EndGlobalSection
EndGlobal

112
Program.cs Normal file
View File

@@ -0,0 +1,112 @@
using System;
using System.Runtime.InteropServices;
using System.Threading;
using static MouseSimulator.MouseSimulator;
namespace MouseSimulator
{
public class MouseSimulator
{
// Импорт необходимых функций из user32.dll
//[DllImport("user32.dll")]
//private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);
[DllImport("user32.dll")]
private static extern bool GetCursorPos(out POINT lpPoint);
[DllImport("user32.dll")]
private static extern bool SetCursorPos(int x, int y);
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int X;
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)
{
SetCursorPos(x, y);
}
// Поулчение позиции курсора
public static POINT GetPosition()
{
POINT point;
if (GetCursorPos(out point))
return point;
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
{
static void Main(string[] args)
{
Console.CancelKeyPress += (sender, eventArgs) => {
Console.WriteLine("Сигнал выхода получен. Завершаем процесс...");
Environment.Exit(0);
};
int stepToMove = 1;
int[][] steps =
{
// x y
new int[] { 0, -stepToMove },
new int[] { 0, stepToMove },
new int[] { stepToMove, 0 },
new int[] { -stepToMove, 0 },
};
Console.WriteLine("Чтобы закрыть программу нажмите Ctrl + C");
while (true)
{
foreach (int[] step in steps)
{
POINT currentPosition = GetPosition();
MoveTo(currentPosition.X + step[0], currentPosition.Y + step[1]);
Thread.Sleep(1000);
}
}
}
}
}

View File

@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанные с этой сборкой.
[assembly: AssemblyTitle("MouseSimulator")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MouseSimulator")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// из модели COM задайте для атрибута ComVisible этого типа значение true.
[assembly: ComVisible(false)]
// Следующий GUID представляет идентификатор typelib, если этот проект доступен из модели COM
[assembly: Guid("2fb36a1d-bd2b-47d9-9699-4bd158a9048c")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Номер редакции
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]