Skip to content

Commit 1aeaaf2

Browse files
committed
Add keyevent in Plugin project & Improve Shell plugin code quality
1 parent 4e1d4ab commit 1aeaaf2

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

Flow.Launcher.Infrastructure/NativeMethods.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ GetModuleHandle
1111
GetKeyState
1212
VIRTUAL_KEY
1313

14-
WM_KEYDOWN
15-
WM_KEYUP
16-
WM_SYSKEYDOWN
17-
WM_SYSKEYUP
18-
1914
EnumWindows
2015

2116
DwmSetWindowAttribute

Flow.Launcher.Infrastructure/Hotkey/KeyEvent.cs renamed to Flow.Launcher.Plugin/KeyEvent.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
using Windows.Win32;
22

3-
namespace Flow.Launcher.Infrastructure.Hotkey
3+
namespace Flow.Launcher.Plugin
44
{
5+
/// <summary>
6+
/// Enumeration of key events for
7+
/// <see cref="IPublicAPI.RegisterGlobalKeyboardCallback(System.Func{int, int, SpecialKeyState, bool})"/>
8+
/// and <see cref="IPublicAPI.RemoveGlobalKeyboardCallback(System.Func{int, int, SpecialKeyState, bool})"/>
9+
/// </summary>
510
public enum KeyEvent
611
{
712
/// <summary>
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
EnumThreadWindows
22
GetWindowText
3-
GetWindowTextLength
3+
GetWindowTextLength
4+
5+
WM_KEYDOWN
6+
WM_KEYUP
7+
WM_SYSKEYDOWN
8+
WM_SYSKEYUP

Plugins/Flow.Launcher.Plugin.Shell/Flow.Launcher.Plugin.Shell.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
</PropertyGroup>
3838

3939
<ItemGroup>
40-
<ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
4140
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
4241
</ItemGroup>
4342

Plugins/Flow.Launcher.Plugin.Shell/Main.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Threading.Tasks;
88
using WindowsInput;
99
using WindowsInput.Native;
10-
using Flow.Launcher.Infrastructure.Hotkey;
1110
using Flow.Launcher.Plugin.SharedCommands;
1211
using Control = System.Windows.Controls.Control;
1312
using Keys = System.Windows.Forms.Keys;
@@ -22,7 +21,7 @@ public class Main : IPlugin, ISettingProvider, IPluginI18n, IContextMenu
2221

2322
private const string Image = "Images/shell.png";
2423
private bool _winRStroked;
25-
private readonly KeyboardSimulator _keyboardSimulator = new KeyboardSimulator(new InputSimulator());
24+
private readonly KeyboardSimulator _keyboardSimulator = new(new InputSimulator());
2625

2726
private Settings _settings;
2827

@@ -55,7 +54,7 @@ public List<Result> Query(Query query)
5554
{
5655
basedir = Path.GetDirectoryName(excmd);
5756
var dirName = Path.GetDirectoryName(cmd);
58-
dir = (dirName.EndsWith("/") || dirName.EndsWith(@"\")) ? dirName : cmd.Substring(0, dirName.Length + 1);
57+
dir = (dirName.EndsWith("/") || dirName.EndsWith(@"\")) ? dirName : cmd[..(dirName.Length + 1)];
5958
}
6059

6160
if (basedir != null)
@@ -321,7 +320,7 @@ private void Execute(Func<ProcessStartInfo, Process> startProcess, ProcessStartI
321320
}
322321
}
323322

324-
private bool ExistInPath(string filename)
323+
private static bool ExistInPath(string filename)
325324
{
326325
if (File.Exists(filename))
327326
{

0 commit comments

Comments
 (0)