Skip to content

Commit

Permalink
refactor(KBEHtool):重构项目并支持 .NET 9
Browse files Browse the repository at this point in the history
- 更新 KBEHtool.csproj 文件,添加对 .NET9 的支持
- 重命名 KBEHtool.Wpf.Test项目为 KBEHtool.Wpf.Demo
- 修改 KBEH.cs 中的方法名称,简化为 Start 和 Stop
- 更新 .gitignore 文件,适应新的项目结构
- 移除多余的 MainWindow.xaml 和 App.xaml 文件
  • Loading branch information
DanKE123abc committed Jan 17, 2025
1 parent d48ca58 commit b82f9e9
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 18 deletions.
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
/KEBHtool/bin/
/KEBHtool/lib/
/KEBHtool/obj/
/KEBHtool.Wpf.Test/bin/
/KEBHtool.Wpf.Test/obj/
/KEBHtool.Wpf.Demo/bin/
/KEBHtool.Wpf.Demo/obj/
/publish/
*.nupkg
/publish/KEBHtool
/publish
/KBEHtool/obj
/KBEHtool/lib
/KBEHtool.Wpf.Test/obj
/KBEHtool.Wpf.Test/bin
/KBEHtool.Wpf.Test/bin
/KBEHtool.Wpf.Test/bin
/KBEHtool.Wpf.Demo/obj
/KBEHtool.Wpf.Demo/bin
/KBEHtool.Wpf.Demo/bin
/KBEHtool.Wpf.Demo/bin
/KBEHtool/bin
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<TargetFramework>net9.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<RootNamespace>KBEHtool.Wpf.Test</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class MainWindow : Window
public MainWindow()
{
IntPtr handle = new WindowInteropHelper(this).Handle;
KBEH.StartKBEH();
KBEH.Start();
InitializeComponent();
KeyAction.AddKeyDownListener((keycode) => MyKeyDown(keycode));
KeyAction.AddKeyUpListener((keycode) => MyKeyUp(keycode));
Expand Down Expand Up @@ -51,13 +51,13 @@ private void DispatcherTimer_Tick(object sender, EventArgs e)

private void Window_Closed(object sender, EventArgs e)
{
KBEH.StopKBEH();
KBEH.Stop();
}

private void PressVBK(object sender, RoutedEventArgs e)
{
//KeyAction.PressKey(KeyCode.A,1000);
KeyAction.PressKey(new [] { KeyCode.LeftControl , KeyCode.Space},1000);
KeyAction.PressKey(new [] { KeyCode.LeftAlt , KeyCode.A},1000);//打开微信截图
}
}
}
2 changes: 1 addition & 1 deletion KBEHtool.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KBEHtool", "KBEHtool\KBEHtool.csproj", "{6D7F396C-5E30-4961-A8D0-2B428CFFEC93}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KBEHtool.Wpf.Test", "KBEHtool.Wpf.Test\KBEHtool.Wpf.Test.csproj", "{D19930F6-B3AC-40C2-92AA-B253677F87CF}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KBEHtool.Wpf.Demo", "KBEHtool.Wpf.Demo\KBEHtool.Wpf.Demo.csproj", "{D19930F6-B3AC-40C2-92AA-B253677F87CF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
8 changes: 2 additions & 6 deletions KBEHtool/KBEH.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class KBEH
private static bool isRunning = false;
private static KeyboardHook keyboardHook= null;

public static bool StartKBEH()
public static bool Start()
{
if (!isRunning)
{
Expand All @@ -20,15 +20,13 @@ public static bool StartKBEH()
}
catch (Exception e)
{
Console.WriteLine(e);
return false;
}
}
Console.WriteLine("KBEH service already running");
return true;
}

public static bool StopKBEH()
public static bool Stop()
{
if (isRunning)
{
Expand All @@ -41,11 +39,9 @@ public static bool StopKBEH()
}
catch (Exception e)
{
Console.WriteLine(e);
return false;
}
}
Console.WriteLine("KBEH service has stopped running");
return true;
}
}
2 changes: 1 addition & 1 deletion KBEHtool/KBEHtool.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0-windows;net7.0-windows;net6.0-windows</TargetFrameworks>
<TargetFrameworks>net9.0-windows;net8.0-windows;net7.0-windows;net6.0-windows</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
Expand Down

0 comments on commit b82f9e9

Please sign in to comment.