Compare commits
3 Commits
c1a425a7ad
...
6aa49c0b07
| Author | SHA1 | Date | |
|---|---|---|---|
| 6aa49c0b07 | |||
| 52a2515e2d | |||
| 742c1d70fe |
@@ -18,12 +18,12 @@
|
|||||||
<PackageCertificateThumbprint>4A55954F2A73A9D620442C7DFBFC7C95A71D8D24</PackageCertificateThumbprint>
|
<PackageCertificateThumbprint>4A55954F2A73A9D620442C7DFBFC7C95A71D8D24</PackageCertificateThumbprint>
|
||||||
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
|
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
|
||||||
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
|
<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>
|
<AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
|
||||||
<GenerateTestArtifacts>True</GenerateTestArtifacts>
|
<GenerateTestArtifacts>True</GenerateTestArtifacts>
|
||||||
<AppxBundle>Auto</AppxBundle>
|
<AppxBundle>Auto</AppxBundle>
|
||||||
<AppxBundlePlatforms>x64</AppxBundlePlatforms>
|
<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>
|
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Microsoft.UI.Xaml;
|
using Microsoft.UI.Xaml;
|
||||||
|
|
||||||
@@ -6,40 +6,50 @@ namespace ClipForge
|
|||||||
{
|
{
|
||||||
public class GlobalHotkeyService
|
public class GlobalHotkeyService
|
||||||
{
|
{
|
||||||
// These two lines talk directly to Windows to register/unregister hotkeys
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);
|
private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
|
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
|
||||||
|
|
||||||
// This is the ID we'll use to identify our clip hotkey
|
|
||||||
private const int HOTKEY_CLIP = 1;
|
private const int HOTKEY_CLIP = 1;
|
||||||
|
private const uint MOD_NOREPEAT = 0x4000; // don't fire on key repeat
|
||||||
|
|
||||||
// Alt key modifier
|
|
||||||
private const uint MOD_ALT = 0x0001;
|
|
||||||
|
|
||||||
// F9 key
|
|
||||||
private const uint VK_F9 = 0x78;
|
|
||||||
|
|
||||||
// This is the "event" that fires when the hotkey is pressed
|
|
||||||
public event Action? ClipRequested;
|
public event Action? ClipRequested;
|
||||||
|
|
||||||
private IntPtr _hwnd;
|
private IntPtr _hwnd;
|
||||||
|
private uint _modifiers;
|
||||||
|
private uint _vk;
|
||||||
|
|
||||||
public void Initialize(IntPtr hwnd)
|
/// <summary>Register the clip hotkey. Use settings values (e.g. HotkeyModifiers, HotkeyVirtualKey).</summary>
|
||||||
|
public void Initialize(IntPtr hwnd, uint modifiers, uint vk)
|
||||||
{
|
{
|
||||||
_hwnd = hwnd;
|
_hwnd = hwnd;
|
||||||
RegisterHotKey(_hwnd, HOTKEY_CLIP, MOD_ALT, VK_F9);
|
_modifiers = modifiers;
|
||||||
|
_vk = vk;
|
||||||
|
TryRegister();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Update the hotkey at runtime (e.g. after user remaps). Unregisters old and registers new.</summary>
|
||||||
|
public bool UpdateHotkey(uint modifiers, uint vk)
|
||||||
|
{
|
||||||
|
UnregisterHotKey(_hwnd, HOTKEY_CLIP);
|
||||||
|
_modifiers = modifiers;
|
||||||
|
_vk = vk;
|
||||||
|
return TryRegister();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool TryRegister()
|
||||||
|
{
|
||||||
|
uint mod = _modifiers | MOD_NOREPEAT;
|
||||||
|
return RegisterHotKey(_hwnd, HOTKEY_CLIP, mod, _vk);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessHotkey(int id)
|
public void ProcessHotkey(int id)
|
||||||
{
|
{
|
||||||
if (id == HOTKEY_CLIP)
|
if (id == HOTKEY_CLIP)
|
||||||
{
|
|
||||||
ClipRequested?.Invoke();
|
ClipRequested?.Invoke();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void Cleanup()
|
public void Cleanup()
|
||||||
{
|
{
|
||||||
|
|||||||
175
ClipForge/HotkeyHelper.cs
Normal file
175
ClipForge/HotkeyHelper.cs
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Windows.System;
|
||||||
|
|
||||||
|
namespace ClipForge
|
||||||
|
{
|
||||||
|
/// <summary>Converts between hotkey modifier/vk and display strings.</summary>
|
||||||
|
public static class HotkeyHelper
|
||||||
|
{
|
||||||
|
public const uint MOD_ALT = 0x0001;
|
||||||
|
public const uint MOD_CONTROL = 0x0002;
|
||||||
|
public const uint MOD_SHIFT = 0x0004;
|
||||||
|
public const uint MOD_WIN = 0x0008;
|
||||||
|
public const uint MOD_NOREPEAT = 0x4000;
|
||||||
|
|
||||||
|
private static readonly Dictionary<VirtualKey, string> KeyNames = new()
|
||||||
|
{
|
||||||
|
{ VirtualKey.LeftButton, "LMB" },
|
||||||
|
{ VirtualKey.RightButton, "RMB" },
|
||||||
|
{ VirtualKey.Cancel, "Cancel" },
|
||||||
|
{ VirtualKey.Back, "Backspace" },
|
||||||
|
{ VirtualKey.Tab, "Tab" },
|
||||||
|
{ VirtualKey.Clear, "Clear" },
|
||||||
|
{ VirtualKey.Enter, "Enter" },
|
||||||
|
{ VirtualKey.Shift, "Shift" },
|
||||||
|
{ VirtualKey.Control, "Ctrl" },
|
||||||
|
{ VirtualKey.Menu, "Alt" },
|
||||||
|
{ VirtualKey.Pause, "Pause" },
|
||||||
|
{ VirtualKey.CapitalLock, "Caps Lock" },
|
||||||
|
{ VirtualKey.Kana, "Kana" },
|
||||||
|
{ VirtualKey.Hangul, "Hangul" },
|
||||||
|
{ VirtualKey.Junja, "Junja" },
|
||||||
|
{ VirtualKey.Final, "Final" },
|
||||||
|
{ VirtualKey.Hanja, "Hanja" },
|
||||||
|
{ VirtualKey.Kanji, "Kanji" },
|
||||||
|
{ VirtualKey.Escape, "Escape" },
|
||||||
|
{ VirtualKey.Convert, "Convert" },
|
||||||
|
{ VirtualKey.NonConvert, "NonConvert" },
|
||||||
|
{ VirtualKey.Accept, "Accept" },
|
||||||
|
{ VirtualKey.ModeChange, "ModeChange" },
|
||||||
|
{ VirtualKey.Space, "Space" },
|
||||||
|
{ VirtualKey.PageUp, "PgUp" },
|
||||||
|
{ VirtualKey.PageDown, "PgDn" },
|
||||||
|
{ VirtualKey.End, "End" },
|
||||||
|
{ VirtualKey.Home, "Home" },
|
||||||
|
{ VirtualKey.Left, "Left" },
|
||||||
|
{ VirtualKey.Up, "Up" },
|
||||||
|
{ VirtualKey.Right, "Right" },
|
||||||
|
{ VirtualKey.Down, "Down" },
|
||||||
|
{ VirtualKey.Select, "Select" },
|
||||||
|
{ VirtualKey.Print, "Print" },
|
||||||
|
{ VirtualKey.Execute, "Execute" },
|
||||||
|
{ VirtualKey.Snapshot, "Print Screen" },
|
||||||
|
{ VirtualKey.Insert, "Insert" },
|
||||||
|
{ VirtualKey.Delete, "Delete" },
|
||||||
|
{ VirtualKey.Help, "Help" },
|
||||||
|
{ VirtualKey.Number0, "0" },
|
||||||
|
{ VirtualKey.Number1, "1" },
|
||||||
|
{ VirtualKey.Number2, "2" },
|
||||||
|
{ VirtualKey.Number3, "3" },
|
||||||
|
{ VirtualKey.Number4, "4" },
|
||||||
|
{ VirtualKey.Number5, "5" },
|
||||||
|
{ VirtualKey.Number6, "6" },
|
||||||
|
{ VirtualKey.Number7, "7" },
|
||||||
|
{ VirtualKey.Number8, "8" },
|
||||||
|
{ VirtualKey.Number9, "9" },
|
||||||
|
{ VirtualKey.A, "A" },
|
||||||
|
{ VirtualKey.B, "B" },
|
||||||
|
{ VirtualKey.C, "C" },
|
||||||
|
{ VirtualKey.D, "D" },
|
||||||
|
{ VirtualKey.E, "E" },
|
||||||
|
{ VirtualKey.F, "F" },
|
||||||
|
{ VirtualKey.G, "G" },
|
||||||
|
{ VirtualKey.H, "H" },
|
||||||
|
{ VirtualKey.I, "I" },
|
||||||
|
{ VirtualKey.J, "J" },
|
||||||
|
{ VirtualKey.K, "K" },
|
||||||
|
{ VirtualKey.L, "L" },
|
||||||
|
{ VirtualKey.M, "M" },
|
||||||
|
{ VirtualKey.N, "N" },
|
||||||
|
{ VirtualKey.O, "O" },
|
||||||
|
{ VirtualKey.P, "P" },
|
||||||
|
{ VirtualKey.Q, "Q" },
|
||||||
|
{ VirtualKey.R, "R" },
|
||||||
|
{ VirtualKey.S, "S" },
|
||||||
|
{ VirtualKey.T, "T" },
|
||||||
|
{ VirtualKey.U, "U" },
|
||||||
|
{ VirtualKey.V, "V" },
|
||||||
|
{ VirtualKey.W, "W" },
|
||||||
|
{ VirtualKey.X, "X" },
|
||||||
|
{ VirtualKey.Y, "Y" },
|
||||||
|
{ VirtualKey.Z, "Z" },
|
||||||
|
{ VirtualKey.LeftWindows, "Win" },
|
||||||
|
{ VirtualKey.RightWindows, "Win" },
|
||||||
|
{ VirtualKey.Application, "App" },
|
||||||
|
{ VirtualKey.Sleep, "Sleep" },
|
||||||
|
{ VirtualKey.NumberPad0, "Num 0" },
|
||||||
|
{ VirtualKey.NumberPad1, "Num 1" },
|
||||||
|
{ VirtualKey.NumberPad2, "Num 2" },
|
||||||
|
{ VirtualKey.NumberPad3, "Num 3" },
|
||||||
|
{ VirtualKey.NumberPad4, "Num 4" },
|
||||||
|
{ VirtualKey.NumberPad5, "Num 5" },
|
||||||
|
{ VirtualKey.NumberPad6, "Num 6" },
|
||||||
|
{ VirtualKey.NumberPad7, "Num 7" },
|
||||||
|
{ VirtualKey.NumberPad8, "Num 8" },
|
||||||
|
{ VirtualKey.NumberPad9, "Num 9" },
|
||||||
|
{ VirtualKey.Multiply, "Num *" },
|
||||||
|
{ VirtualKey.Add, "Num +" },
|
||||||
|
{ VirtualKey.Separator, "Num ," },
|
||||||
|
{ VirtualKey.Subtract, "Num -" },
|
||||||
|
{ VirtualKey.Decimal, "Num ." },
|
||||||
|
{ VirtualKey.Divide, "Num /" },
|
||||||
|
{ VirtualKey.F1, "F1" },
|
||||||
|
{ VirtualKey.F2, "F2" },
|
||||||
|
{ VirtualKey.F3, "F3" },
|
||||||
|
{ VirtualKey.F4, "F4" },
|
||||||
|
{ VirtualKey.F5, "F5" },
|
||||||
|
{ VirtualKey.F6, "F6" },
|
||||||
|
{ VirtualKey.F7, "F7" },
|
||||||
|
{ VirtualKey.F8, "F8" },
|
||||||
|
{ VirtualKey.F9, "F9" },
|
||||||
|
{ VirtualKey.F10, "F10" },
|
||||||
|
{ VirtualKey.F11, "F11" },
|
||||||
|
{ VirtualKey.F12, "F12" },
|
||||||
|
{ VirtualKey.F13, "F13" },
|
||||||
|
{ VirtualKey.F14, "F14" },
|
||||||
|
{ VirtualKey.F15, "F15" },
|
||||||
|
{ VirtualKey.F16, "F16" },
|
||||||
|
{ VirtualKey.F17, "F17" },
|
||||||
|
{ VirtualKey.F18, "F18" },
|
||||||
|
{ VirtualKey.F19, "F19" },
|
||||||
|
{ VirtualKey.F20, "F20" },
|
||||||
|
{ VirtualKey.F21, "F21" },
|
||||||
|
{ VirtualKey.F22, "F22" },
|
||||||
|
{ VirtualKey.F23, "F23" },
|
||||||
|
{ VirtualKey.F24, "F24" },
|
||||||
|
{ VirtualKey.NumberKeyLock, "NumLock" },
|
||||||
|
{ VirtualKey.Scroll, "Scroll Lock" },
|
||||||
|
{ VirtualKey.LeftShift, "Shift" },
|
||||||
|
{ VirtualKey.RightShift, "Shift" },
|
||||||
|
{ VirtualKey.LeftControl, "Ctrl" },
|
||||||
|
{ VirtualKey.RightControl, "Ctrl" },
|
||||||
|
{ VirtualKey.LeftMenu, "Alt" },
|
||||||
|
{ VirtualKey.RightMenu, "Alt" },
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>Format modifier flags + virtual key as display string (e.g. "Alt + PgUp").</summary>
|
||||||
|
public static string ToDisplayString(uint modifiers, uint vk)
|
||||||
|
{
|
||||||
|
var parts = new List<string>();
|
||||||
|
if ((modifiers & MOD_WIN) != 0) parts.Add("Win");
|
||||||
|
if ((modifiers & MOD_CONTROL) != 0) parts.Add("Ctrl");
|
||||||
|
if ((modifiers & MOD_ALT) != 0) parts.Add("Alt");
|
||||||
|
if ((modifiers & MOD_SHIFT) != 0) parts.Add("Shift");
|
||||||
|
var keyName = GetKeyName((VirtualKey)vk);
|
||||||
|
if (!string.IsNullOrEmpty(keyName))
|
||||||
|
parts.Add(keyName);
|
||||||
|
return parts.Count > 0 ? string.Join(" + ", parts) : "None";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetKeyName(VirtualKey key)
|
||||||
|
{
|
||||||
|
return KeyNames.TryGetValue(key, out var name) ? name : key.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>True if the key is typically used only as a modifier (don't use as sole key).</summary>
|
||||||
|
public static bool IsModifierKey(VirtualKey key)
|
||||||
|
{
|
||||||
|
return key == VirtualKey.LeftWindows || key == VirtualKey.RightWindows
|
||||||
|
|| key == VirtualKey.Control || key == VirtualKey.LeftControl || key == VirtualKey.RightControl
|
||||||
|
|| key == VirtualKey.Menu || key == VirtualKey.LeftMenu || key == VirtualKey.RightMenu
|
||||||
|
|| key == VirtualKey.Shift || key == VirtualKey.LeftShift || key == VirtualKey.RightShift;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -371,22 +371,24 @@
|
|||||||
FontWeight="SemiBold"
|
FontWeight="SemiBold"
|
||||||
VerticalAlignment="Center"/>
|
VerticalAlignment="Center"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<TextBlock Text="The key combination to save a clip."
|
<TextBlock Text="Click the key below, then press your desired combination."
|
||||||
FontSize="12"
|
FontSize="12"
|
||||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"/>
|
Foreground="{ThemeResource TextFillColorSecondaryBrush}"/>
|
||||||
<Border Background="#1a1a2e"
|
<Button x:Name="HotkeyRecorderButton"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Click="HotkeyRecorderButton_Click"
|
||||||
|
Background="#1a1a2e"
|
||||||
|
BorderThickness="0"
|
||||||
CornerRadius="6"
|
CornerRadius="6"
|
||||||
Padding="16,10"
|
Padding="16,10"
|
||||||
HorizontalAlignment="Left">
|
MinWidth="140">
|
||||||
<TextBlock Text="Alt + F9"
|
<TextBlock x:Name="HotkeyRecorderText"
|
||||||
|
Text="Alt + F9"
|
||||||
FontFamily="Consolas"
|
FontFamily="Consolas"
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
FontWeight="Bold"
|
FontWeight="Bold"
|
||||||
Foreground="#E8FF47"/>
|
Foreground="#E8FF47"/>
|
||||||
</Border>
|
</Button>
|
||||||
<TextBlock Text="Hotkey remapping coming in a future update."
|
|
||||||
FontSize="11"
|
|
||||||
Foreground="{ThemeResource TextFillColorTertiaryBrush}"/>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
using Microsoft.UI.Xaml;
|
using Microsoft.UI.Xaml;
|
||||||
using Microsoft.UI.Xaml.Controls;
|
using Microsoft.UI.Xaml.Controls;
|
||||||
|
using Microsoft.UI.Xaml.Input;
|
||||||
using Microsoft.UI.Xaml.Media.Animation;
|
using Microsoft.UI.Xaml.Media.Animation;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using Windows.System;
|
||||||
using WinRT.Interop;
|
using WinRT.Interop;
|
||||||
|
|
||||||
namespace ClipForge
|
namespace ClipForge
|
||||||
@@ -16,6 +18,7 @@ namespace ClipForge
|
|||||||
private ClipLibraryService _clipLibrary;
|
private ClipLibraryService _clipLibrary;
|
||||||
private SettingsService _settingsService;
|
private SettingsService _settingsService;
|
||||||
private ThumbnailService _thumbnailService;
|
private ThumbnailService _thumbnailService;
|
||||||
|
private bool _isRecordingHotkey;
|
||||||
|
|
||||||
private delegate IntPtr WinProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
|
private delegate IntPtr WinProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
|
||||||
private WinProc _newWndProc;
|
private WinProc _newWndProc;
|
||||||
@@ -41,6 +44,13 @@ namespace ClipForge
|
|||||||
private static extern IntPtr SendMessage(IntPtr hWnd, uint msg,
|
private static extern IntPtr SendMessage(IntPtr hWnd, uint msg,
|
||||||
IntPtr wParam, IntPtr lParam);
|
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 int GWLP_WNDPROC = -4;
|
||||||
private const uint WM_HOTKEY = 0x0312;
|
private const uint WM_HOTKEY = 0x0312;
|
||||||
private const int GWL_EXSTYLE = -20;
|
private const int GWL_EXSTYLE = -20;
|
||||||
@@ -78,7 +88,10 @@ namespace ClipForge
|
|||||||
|
|
||||||
_hotkeyService = new GlobalHotkeyService();
|
_hotkeyService = new GlobalHotkeyService();
|
||||||
_hotkeyService.ClipRequested += OnClipRequested;
|
_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;
|
ClipGrid.ItemsSource = _clipLibrary.Clips;
|
||||||
UpdateClipCount();
|
UpdateClipCount();
|
||||||
@@ -169,6 +182,8 @@ namespace ClipForge
|
|||||||
QualityLabel.Text = $"{s.VideoQuality}%";
|
QualityLabel.Text = $"{s.VideoQuality}%";
|
||||||
FramerateCombo.SelectedIndex = s.Framerate == 30 ? 0 : 1;
|
FramerateCombo.SelectedIndex = s.Framerate == 30 ? 0 : 1;
|
||||||
StartupToggle.IsOn = IsStartupEnabled();
|
StartupToggle.IsOn = IsStartupEnabled();
|
||||||
|
if (HotkeyRecorderText != null)
|
||||||
|
HotkeyRecorderText.Text = HotkeyHelper.ToDisplayString((uint)s.HotkeyModifiers, (uint)s.HotkeyVirtualKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- STARTUP WITH WINDOWS ---
|
// --- STARTUP WITH WINDOWS ---
|
||||||
@@ -235,6 +250,42 @@ namespace ClipForge
|
|||||||
_ = ShowToastAsync("✅ Settings saved!");
|
_ = ShowToastAsync("✅ Settings saved!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- CUSTOM HOTKEY ---
|
||||||
|
private void HotkeyRecorderButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (_isRecordingHotkey) return;
|
||||||
|
_isRecordingHotkey = true;
|
||||||
|
HotkeyRecorderText.Text = "Press any key...";
|
||||||
|
this.KeyDown += OnHotkeyCaptureKeyDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnHotkeyCaptureKeyDown(object sender, KeyRoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (!_isRecordingHotkey) return;
|
||||||
|
e.Handled = true;
|
||||||
|
|
||||||
|
var key = e.Key;
|
||||||
|
if (HotkeyHelper.IsModifierKey(key))
|
||||||
|
return; // wait for a non-modifier key
|
||||||
|
|
||||||
|
uint mod = 0;
|
||||||
|
if ((GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0) mod |= HotkeyHelper.MOD_CONTROL;
|
||||||
|
if ((GetAsyncKeyState(VK_MENU) & 0x8000) != 0) mod |= HotkeyHelper.MOD_ALT;
|
||||||
|
if ((GetAsyncKeyState(VK_SHIFT) & 0x8000) != 0) mod |= HotkeyHelper.MOD_SHIFT;
|
||||||
|
if ((GetAsyncKeyState(VK_LWIN) & 0x8000) != 0) mod |= HotkeyHelper.MOD_WIN;
|
||||||
|
|
||||||
|
uint vk = (uint)key;
|
||||||
|
_settingsService.Settings.HotkeyModifiers = (int)mod;
|
||||||
|
_settingsService.Settings.HotkeyVirtualKey = (int)vk;
|
||||||
|
|
||||||
|
var ok = _hotkeyService.UpdateHotkey(mod, vk);
|
||||||
|
var display = HotkeyHelper.ToDisplayString(mod, vk);
|
||||||
|
HotkeyRecorderText.Text = ok ? display : display + " (in use?)";
|
||||||
|
|
||||||
|
this.KeyDown -= OnHotkeyCaptureKeyDown;
|
||||||
|
_isRecordingHotkey = false;
|
||||||
|
}
|
||||||
|
|
||||||
// --- NAV ---
|
// --- NAV ---
|
||||||
private void NavClips_Click(object sender, RoutedEventArgs e)
|
private void NavClips_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<Identity
|
<Identity
|
||||||
Name="735fb287-32b4-4217-b84a-302365dc5e23"
|
Name="735fb287-32b4-4217-b84a-302365dc5e23"
|
||||||
Publisher="CN=SCOPEDD"
|
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"/>
|
<mp:PhoneIdentity PhoneProductId="735fb287-32b4-4217-b84a-302365dc5e23" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
@@ -9,7 +9,10 @@ namespace ClipForge
|
|||||||
public int ClipLengthSeconds { get; set; } = 30;
|
public int ClipLengthSeconds { get; set; } = 30;
|
||||||
public int VideoQuality { get; set; } = 70;
|
public int VideoQuality { get; set; } = 70;
|
||||||
public int Framerate { get; set; } = 60;
|
public int Framerate { get; set; } = 60;
|
||||||
public string HotkeyDisplay { get; set; } = "Alt + F9";
|
/// <summary>Windows modifier flags: Alt=1, Ctrl=2, Shift=4, Win=8.</summary>
|
||||||
|
public int HotkeyModifiers { get; set; } = 1; // MOD_ALT
|
||||||
|
/// <summary>Windows virtual key code (e.g. VK_F9=0x78, VK_PRIOR=0x21 for PgUp).</summary>
|
||||||
|
public int HotkeyVirtualKey { get; set; } = 0x78; // VK_F9
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SettingsService
|
public class SettingsService
|
||||||
|
|||||||
Reference in New Issue
Block a user