anshdadhich commited on
Commit
0184607
·
verified ·
1 Parent(s): 7d40f61

Upload FastSeekWpf/App.xaml.cs

Browse files
Files changed (1) hide show
  1. FastSeekWpf/App.xaml.cs +5 -2
FastSeekWpf/App.xaml.cs CHANGED
@@ -14,7 +14,7 @@ public partial class App : Application
14
  private const string MutexName = "FastSeekWpf_SingleInstance_Mutex";
15
  private const uint WM_TOGGLE_WINDOW = Win32Api.WM_USER + 3;
16
  private Mutex? _mutex;
17
- private bool _shutdown;
18
  private MainWindow? _mainWindow;
19
  private Thread? _hotkeyThread;
20
 
@@ -24,7 +24,7 @@ public partial class App : Application
24
  _mutex = new Mutex(true, MutexName, out bool createdNew);
25
  if (!createdNew)
26
  {
27
- IntPtr hwnd = Win32Api.FindWindowW("FastSeekWpf_MainWindow", null);
28
  if (hwnd != IntPtr.Zero)
29
  Win32Api.PostMessageW(hwnd, WM_TOGGLE_WINDOW, IntPtr.Zero, IntPtr.Zero);
30
  Shutdown();
@@ -59,7 +59,10 @@ public partial class App : Application
59
 
60
  // Register Alt+Space (MOD_ALT=0x0001, VK_SPACE=0x20)
61
  if (!Win32Api.RegisterHotKey(IntPtr.Zero, 1, 0x0001, 0x20))
 
 
62
  return;
 
63
 
64
  try
65
  {
 
14
  private const string MutexName = "FastSeekWpf_SingleInstance_Mutex";
15
  private const uint WM_TOGGLE_WINDOW = Win32Api.WM_USER + 3;
16
  private Mutex? _mutex;
17
+ private volatile bool _shutdown;
18
  private MainWindow? _mainWindow;
19
  private Thread? _hotkeyThread;
20
 
 
24
  _mutex = new Mutex(true, MutexName, out bool createdNew);
25
  if (!createdNew)
26
  {
27
+ IntPtr hwnd = Win32Api.FindWindowW(null, "FastSeek");
28
  if (hwnd != IntPtr.Zero)
29
  Win32Api.PostMessageW(hwnd, WM_TOGGLE_WINDOW, IntPtr.Zero, IntPtr.Zero);
30
  Shutdown();
 
59
 
60
  // Register Alt+Space (MOD_ALT=0x0001, VK_SPACE=0x20)
61
  if (!Win32Api.RegisterHotKey(IntPtr.Zero, 1, 0x0001, 0x20))
62
+ {
63
+ Debug.WriteLine($"RegisterHotKey failed: {Marshal.GetLastWin32Error()}");
64
  return;
65
+ }
66
 
67
  try
68
  {