Add project files.

This commit is contained in:
Blade / SCOPEDD
2026-02-22 11:31:35 -05:00
parent 3612bf40db
commit c1a425a7ad
84 changed files with 2323 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
using System;
using System.Runtime.InteropServices;
using Microsoft.UI.Xaml;
namespace ClipForge
{
public class GlobalHotkeyService
{
// These two lines talk directly to Windows to register/unregister hotkeys
[DllImport("user32.dll")]
private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);
[DllImport("user32.dll")]
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;
// 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;
private IntPtr _hwnd;
public void Initialize(IntPtr hwnd)
{
_hwnd = hwnd;
RegisterHotKey(_hwnd, HOTKEY_CLIP, MOD_ALT, VK_F9);
}
public void ProcessHotkey(int id)
{
if (id == HOTKEY_CLIP)
{
ClipRequested?.Invoke();
}
}
public void Cleanup()
{
UnregisterHotKey(_hwnd, HOTKEY_CLIP);
}
}
}