mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix non-elevated auto click
This commit is contained in:
@@ -16,22 +16,34 @@ internal sealed class HotKeyController : IHotKeyController
|
|||||||
private readonly object locker = new();
|
private readonly object locker = new();
|
||||||
private readonly WaitCallback runMouseClickRepeatForever;
|
private readonly WaitCallback runMouseClickRepeatForever;
|
||||||
private readonly HotKeyOptions hotKeyOptions;
|
private readonly HotKeyOptions hotKeyOptions;
|
||||||
|
private readonly RuntimeOptions runtimeOptions;
|
||||||
private volatile CancellationTokenSource? cancellationTokenSource;
|
private volatile CancellationTokenSource? cancellationTokenSource;
|
||||||
|
|
||||||
public HotKeyController(IServiceProvider serviceProvider)
|
public HotKeyController(IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
hotKeyOptions = serviceProvider.GetRequiredService<HotKeyOptions>();
|
hotKeyOptions = serviceProvider.GetRequiredService<HotKeyOptions>();
|
||||||
|
runtimeOptions = serviceProvider.GetRequiredService<RuntimeOptions>();
|
||||||
runMouseClickRepeatForever = MouseClickRepeatForever;
|
runMouseClickRepeatForever = MouseClickRepeatForever;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Register(in HWND hwnd)
|
public bool Register(in HWND hwnd)
|
||||||
{
|
{
|
||||||
return RegisterHotKey(hwnd, DefaultId, default, (uint)VIRTUAL_KEY.VK_F8);
|
if (runtimeOptions.IsElevated)
|
||||||
|
{
|
||||||
|
return RegisterHotKey(hwnd, DefaultId, default, (uint)VIRTUAL_KEY.VK_F8);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Unregister(in HWND hwnd)
|
public bool Unregister(in HWND hwnd)
|
||||||
{
|
{
|
||||||
return UnregisterHotKey(hwnd, DefaultId);
|
if (runtimeOptions.IsElevated)
|
||||||
|
{
|
||||||
|
return UnregisterHotKey(hwnd, DefaultId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnHotKeyPressed(in HotKeyParameter parameter)
|
public void OnHotKeyPressed(in HotKeyParameter parameter)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace Snap.Hutao.Core.Windowing.HotKey;
|
|||||||
internal interface IHotKeyController
|
internal interface IHotKeyController
|
||||||
{
|
{
|
||||||
void OnHotKeyPressed(in HotKeyParameter parameter);
|
void OnHotKeyPressed(in HotKeyParameter parameter);
|
||||||
|
|
||||||
bool Register(in HWND hwnd);
|
bool Register(in HWND hwnd);
|
||||||
|
|
||||||
bool Unregister(in HWND hwnd);
|
bool Unregister(in HWND hwnd);
|
||||||
|
|||||||
Reference in New Issue
Block a user