Add keyevent in Plugin project & Improve Shell plugin code quality

This commit is contained in:
Jack251970 2025-04-09 12:30:50 +08:00
parent 4e1d4ab7af
commit 1aeaaf2fc2
5 changed files with 15 additions and 12 deletions

View file

@ -11,11 +11,6 @@ GetModuleHandle
GetKeyState
VIRTUAL_KEY
WM_KEYDOWN
WM_KEYUP
WM_SYSKEYDOWN
WM_SYSKEYUP
EnumWindows
DwmSetWindowAttribute

View file

@ -1,7 +1,12 @@
using Windows.Win32;
namespace Flow.Launcher.Infrastructure.Hotkey
namespace Flow.Launcher.Plugin
{
/// <summary>
/// Enumeration of key events for
/// <see cref="IPublicAPI.RegisterGlobalKeyboardCallback(System.Func{int, int, SpecialKeyState, bool})"/>
/// and <see cref="IPublicAPI.RemoveGlobalKeyboardCallback(System.Func{int, int, SpecialKeyState, bool})"/>
/// </summary>
public enum KeyEvent
{
/// <summary>

View file

@ -1,3 +1,8 @@
EnumThreadWindows
GetWindowText
GetWindowTextLength
GetWindowTextLength
WM_KEYDOWN
WM_KEYUP
WM_SYSKEYDOWN
WM_SYSKEYUP

View file

@ -37,7 +37,6 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
</ItemGroup>

View file

@ -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))
{