Skip to content

Commit

Permalink
代码细微改进
Browse files Browse the repository at this point in the history
  • Loading branch information
iMoe committed Apr 23, 2021
1 parent 80e9566 commit db775ea
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 306 deletions.
6 changes: 3 additions & 3 deletions App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
</configuration>
33 changes: 17 additions & 16 deletions Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 64 additions & 60 deletions Form1.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Data;
using System.Drawing;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace MouseClickTool
{/// <summary>
/// 怎么简单怎么来了
/// </summary>
///
public partial class Form1 : Form
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}

//新方法:https://stackoverflow.com/questions/5094398/how-to-programmatically-mouse-move-click-right-click-and-keypress-etc-in-winfo
internal class MouseSimulator
{
Expand Down Expand Up @@ -92,61 +101,56 @@ public Form1()
{
InitializeComponent();
this.comboBox1.SelectedIndex = 0;
this.MaximizeBox = false;
}

private void is_begin_Click(object sender, EventArgs e)
{
if (is_begin.Text == "停止")
is_begin.Click += (s, e) =>
{
Environment.Exit(0);
return;
}
string ms = is_ms.Text;
int result;
if (int.TryParse(ms, out result) && result > 0)
{
is_ms.ReadOnly = true;
Task.Factory.StartNew(async () =>
{
await Task.Run(() =>
{
for (int i = 1; i < 5; i++)
{
is_begin.Text = string.Format("开始({0})", 5 - i);
Thread.Sleep(1000);
}
});
is_begin.Text = string.Format("停止");
if (this.comboBox1.SelectedIndex == 0)
{
for (; ; )
{
await Task.Run(() =>
{
MouseSimulator.ClickLeftMouseButton();
Thread.Sleep(result);
});
}
}
else
{
for (; ; )
{
await Task.Run(() =>
{
MouseSimulator.ClickRightMouseButton();
Thread.Sleep(result);
});
}
}
});
}
else
{
MessageBox.Show("输入的数字不正确,必须是正整数");
}
if (is_begin.Text.Equals("停止"))
{
Environment.Exit(0);
return;
}
if (int.TryParse(is_ms.Text, out int result) && result > 0)
{
is_ms.ReadOnly = true;
Task.Factory.StartNew(async () =>
{
await Task.Run(() =>
{
for (int i = 1; i < 5; i++)
{
is_begin.Text = string.Format("开始({0})", 5 - i);
Thread.Sleep(1000);
}
});
is_begin.Text = "停止";
if (this.comboBox1.SelectedIndex == 0)
{
for (; ; )
{
await Task.Run(() =>
{
MouseSimulator.ClickLeftMouseButton();
Thread.Sleep(result);
});
}
}
else
{
for (; ; )
{
await Task.Run(() =>
{
MouseSimulator.ClickRightMouseButton();
Thread.Sleep(result);
});
}
}
});
}
else
{
MessageBox.Show("输入的数字不正确,必须是正整数");
}
};
}
}
}
14 changes: 3 additions & 11 deletions MouseClickTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>WinExe</OutputType>
<RootNamespace>MouseClickTool</RootNamespace>
<AssemblyName>MouseClickTool</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
Expand All @@ -28,6 +28,7 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
Expand All @@ -40,6 +41,7 @@
<ErrorReport>none</ErrorReport>
<FileAlignment>1024</FileAlignment>
<DebugSymbols>false</DebugSymbols>
<Optimize>true</Optimize>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationFramework" />
Expand Down Expand Up @@ -75,20 +77,10 @@
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="app.manifest" />
</ItemGroup>
<ItemGroup>
Expand Down
22 changes: 0 additions & 22 deletions Program.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("iamverylovely")]
[assembly: AssemblyProduct("MouseClickTool")]
[assembly: AssemblyCopyright("Copyright © 2020 iamverylovely")]
[assembly: AssemblyCopyright("Copyright © 2020 iamverylovely")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
71 changes: 0 additions & 71 deletions Properties/Resources.Designer.cs

This file was deleted.

Loading

0 comments on commit db775ea

Please sign in to comment.