基于WebView2实现的Win11桌面框架,利用插件自定义
chunhualin1
2026-08-17 9b5711d3124622b1f1b18500d442c76492da877a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using Moli.Desktop.Hotkeys;
 
namespace Moli.Desktop.Runtime;
 
public enum HotkeyRegistrationState
{
    Registered,
    Conflict,
    Disabled,
    Invalid
}
 
public sealed record HotkeyRegistration
{
    public required string BindingId { get; init; }
    public required string Keys { get; init; }
    public required HotkeyRegistrationState State { get; init; }
    public string? Detail { get; init; }
}
 
public interface IHotkeyService : IDisposable
{
    event Func<HotkeyBinding, Task>? HotkeyPressed;
    IReadOnlyList<HotkeyRegistration> Registrations { get; }
    Task ReplaceBindingsAsync(IReadOnlyList<HotkeyBinding> bindings, CancellationToken cancellationToken = default);
    void Pause();
    void Resume();
    void UnregisterAll();
}
 
public interface INativeHotkeyApi
{
    bool Register(IntPtr hwnd, int id, uint modifiers, uint virtualKey, out int win32Error);
    bool Unregister(IntPtr hwnd, int id);
}
 
public interface IHotkeyMessageWindow : IDisposable
{
    IntPtr Handle { get; }
    event Action<int>? HotkeyPosted;
    void EnsureCreated();
}