From 1aeaaf2fc24d32d67d994f84b2e84b555fb8c367 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Wed, 9 Apr 2025 12:30:50 +0800
Subject: [PATCH] Add keyevent in Plugin project & Improve Shell plugin code
quality
---
Flow.Launcher.Infrastructure/NativeMethods.txt | 5 -----
.../Hotkey => Flow.Launcher.Plugin}/KeyEvent.cs | 7 ++++++-
Flow.Launcher.Plugin/NativeMethods.txt | 7 ++++++-
.../Flow.Launcher.Plugin.Shell.csproj | 1 -
Plugins/Flow.Launcher.Plugin.Shell/Main.cs | 7 +++----
5 files changed, 15 insertions(+), 12 deletions(-)
rename {Flow.Launcher.Infrastructure/Hotkey => Flow.Launcher.Plugin}/KeyEvent.cs (61%)
diff --git a/Flow.Launcher.Infrastructure/NativeMethods.txt b/Flow.Launcher.Infrastructure/NativeMethods.txt
index 363ecb9d0..18b206022 100644
--- a/Flow.Launcher.Infrastructure/NativeMethods.txt
+++ b/Flow.Launcher.Infrastructure/NativeMethods.txt
@@ -11,11 +11,6 @@ GetModuleHandle
GetKeyState
VIRTUAL_KEY
-WM_KEYDOWN
-WM_KEYUP
-WM_SYSKEYDOWN
-WM_SYSKEYUP
-
EnumWindows
DwmSetWindowAttribute
diff --git a/Flow.Launcher.Infrastructure/Hotkey/KeyEvent.cs b/Flow.Launcher.Plugin/KeyEvent.cs
similarity index 61%
rename from Flow.Launcher.Infrastructure/Hotkey/KeyEvent.cs
rename to Flow.Launcher.Plugin/KeyEvent.cs
index 95bb25837..321f17cc1 100644
--- a/Flow.Launcher.Infrastructure/Hotkey/KeyEvent.cs
+++ b/Flow.Launcher.Plugin/KeyEvent.cs
@@ -1,7 +1,12 @@
using Windows.Win32;
-namespace Flow.Launcher.Infrastructure.Hotkey
+namespace Flow.Launcher.Plugin
{
+ ///
+ /// Enumeration of key events for
+ ///
+ /// and
+ ///
public enum KeyEvent
{
///
diff --git a/Flow.Launcher.Plugin/NativeMethods.txt b/Flow.Launcher.Plugin/NativeMethods.txt
index e3e2b705e..0596691cc 100644
--- a/Flow.Launcher.Plugin/NativeMethods.txt
+++ b/Flow.Launcher.Plugin/NativeMethods.txt
@@ -1,3 +1,8 @@
EnumThreadWindows
GetWindowText
-GetWindowTextLength
\ No newline at end of file
+GetWindowTextLength
+
+WM_KEYDOWN
+WM_KEYUP
+WM_SYSKEYDOWN
+WM_SYSKEYUP
\ No newline at end of file
diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Flow.Launcher.Plugin.Shell.csproj b/Plugins/Flow.Launcher.Plugin.Shell/Flow.Launcher.Plugin.Shell.csproj
index 8f443214b..c7ea7cdd5 100644
--- a/Plugins/Flow.Launcher.Plugin.Shell/Flow.Launcher.Plugin.Shell.csproj
+++ b/Plugins/Flow.Launcher.Plugin.Shell/Flow.Launcher.Plugin.Shell.csproj
@@ -37,7 +37,6 @@
-
diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs
index 97ff61304..b149884d7 100644
--- a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs
@@ -7,7 +7,6 @@ using System.Linq;
using System.Threading.Tasks;
using WindowsInput;
using WindowsInput.Native;
-using Flow.Launcher.Infrastructure.Hotkey;
using Flow.Launcher.Plugin.SharedCommands;
using Control = System.Windows.Controls.Control;
using Keys = System.Windows.Forms.Keys;
@@ -22,7 +21,7 @@ namespace Flow.Launcher.Plugin.Shell
private const string Image = "Images/shell.png";
private bool _winRStroked;
- private readonly KeyboardSimulator _keyboardSimulator = new KeyboardSimulator(new InputSimulator());
+ private readonly KeyboardSimulator _keyboardSimulator = new(new InputSimulator());
private Settings _settings;
@@ -55,7 +54,7 @@ namespace Flow.Launcher.Plugin.Shell
{
basedir = Path.GetDirectoryName(excmd);
var dirName = Path.GetDirectoryName(cmd);
- dir = (dirName.EndsWith("/") || dirName.EndsWith(@"\")) ? dirName : cmd.Substring(0, dirName.Length + 1);
+ dir = (dirName.EndsWith("/") || dirName.EndsWith(@"\")) ? dirName : cmd[..(dirName.Length + 1)];
}
if (basedir != null)
@@ -321,7 +320,7 @@ namespace Flow.Launcher.Plugin.Shell
}
}
- private bool ExistInPath(string filename)
+ private static bool ExistInPath(string filename)
{
if (File.Exists(filename))
{