Enhance GlobalHotkeyService to allow for dynamic hotkey updates and improve user experience with customizable HotkeyModifiers and HotkeyVirtualKey settings.
This commit is contained in:
@@ -18,12 +18,12 @@
|
||||
<PackageCertificateThumbprint>4A55954F2A73A9D620442C7DFBFC7C95A71D8D24</PackageCertificateThumbprint>
|
||||
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
|
||||
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
|
||||
<AppxPackageDir>C:\Users\Blade\Desktop\Clipforge Packaged\V1\</AppxPackageDir>
|
||||
<AppxPackageDir>C:\Users\Blade\Desktop\Clipforge Packaged\V0.1\</AppxPackageDir>
|
||||
<AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
|
||||
<GenerateTestArtifacts>True</GenerateTestArtifacts>
|
||||
<AppxBundle>Auto</AppxBundle>
|
||||
<AppxBundlePlatforms>x64</AppxBundlePlatforms>
|
||||
<AppInstallerUri>J:\Projects\ClipForge\ClipForge\bin\x64\Release\net8.0-windows10.0.19041.0</AppInstallerUri>
|
||||
<AppInstallerUri>C:\Users\Blade\Desktop\Clipforge Packaged</AppInstallerUri>
|
||||
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -371,22 +371,24 @@
|
||||
FontWeight="SemiBold"
|
||||
VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<TextBlock Text="The key combination to save a clip."
|
||||
<TextBlock Text="Click the key below, then press your desired combination."
|
||||
FontSize="12"
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"/>
|
||||
<Border Background="#1a1a2e"
|
||||
<Button x:Name="HotkeyRecorderButton"
|
||||
HorizontalAlignment="Left"
|
||||
Click="HotkeyRecorderButton_Click"
|
||||
Background="#1a1a2e"
|
||||
BorderThickness="0"
|
||||
CornerRadius="6"
|
||||
Padding="16,10"
|
||||
HorizontalAlignment="Left">
|
||||
<TextBlock Text="Alt + F9"
|
||||
MinWidth="140">
|
||||
<TextBlock x:Name="HotkeyRecorderText"
|
||||
Text="Alt + F9"
|
||||
FontFamily="Consolas"
|
||||
FontSize="14"
|
||||
FontWeight="Bold"
|
||||
Foreground="#E8FF47"/>
|
||||
</Border>
|
||||
<TextBlock Text="Hotkey remapping coming in a future update."
|
||||
FontSize="11"
|
||||
Foreground="{ThemeResource TextFillColorTertiaryBrush}"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using Microsoft.UI.Xaml.Media.Animation;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Windows.System;
|
||||
using WinRT.Interop;
|
||||
|
||||
namespace ClipForge
|
||||
@@ -16,6 +18,7 @@ namespace ClipForge
|
||||
private ClipLibraryService _clipLibrary;
|
||||
private SettingsService _settingsService;
|
||||
private ThumbnailService _thumbnailService;
|
||||
private bool _isRecordingHotkey;
|
||||
|
||||
private delegate IntPtr WinProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
|
||||
private WinProc _newWndProc;
|
||||
@@ -41,6 +44,13 @@ namespace ClipForge
|
||||
private static extern IntPtr SendMessage(IntPtr hWnd, uint msg,
|
||||
IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern short GetAsyncKeyState(int vk);
|
||||
|
||||
private const int VK_SHIFT = 0x10;
|
||||
private const int VK_CONTROL = 0x11;
|
||||
private const int VK_MENU = 0x12; // Alt
|
||||
private const int VK_LWIN = 0x5B;
|
||||
private const int GWLP_WNDPROC = -4;
|
||||
private const uint WM_HOTKEY = 0x0312;
|
||||
private const int GWL_EXSTYLE = -20;
|
||||
@@ -78,7 +88,10 @@ namespace ClipForge
|
||||
|
||||
_hotkeyService = new GlobalHotkeyService();
|
||||
_hotkeyService.ClipRequested += OnClipRequested;
|
||||
_hotkeyService.Initialize(hwnd);
|
||||
var mod = _settingsService.Settings.HotkeyModifiers;
|
||||
var vk = _settingsService.Settings.HotkeyVirtualKey;
|
||||
if (mod == 0 && vk == 0) { mod = 1; vk = 0x78; }
|
||||
_hotkeyService.Initialize(hwnd, (uint)mod, (uint)vk);
|
||||
|
||||
ClipGrid.ItemsSource = _clipLibrary.Clips;
|
||||
UpdateClipCount();
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<Identity
|
||||
Name="735fb287-32b4-4217-b84a-302365dc5e23"
|
||||
Publisher="CN=SCOPEDD"
|
||||
Version="1.0.0.0" />
|
||||
Version="0.1.0.0" />
|
||||
|
||||
<mp:PhoneIdentity PhoneProductId="735fb287-32b4-4217-b84a-302365dc5e23" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user