Make ctrl-F16 register windows actually

This commit is contained in:
2025-06-26 18:15:29 +02:00
parent eabda5da67
commit 86a761fe96

View File

@@ -81,42 +81,34 @@ namespace EveOPreview.Services
this._hideThumbnailsDelay = this._configuration.HideThumbnailsDelay; this._hideThumbnailsDelay = this._configuration.HideThumbnailsDelay;
RegisterCycleClientHotkey(this._configuration.CycleGroup1ForwardHotkeys?.Select(x => this._configuration.StringToKey(x)), true, this._configuration.CycleGroup1ClientsOrder); // RegisterCycleClientHotkey(this._configuration.CycleGroup1ForwardHotkeys?.Select(x => this._configuration.StringToKey(x)), true, this._configuration.CycleGroup1ClientsOrder);
RegisterCycleClientHotkey(this._configuration.CycleGroup1BackwardHotkeys?.Select(x => this._configuration.StringToKey(x)), false, this._configuration.CycleGroup1ClientsOrder); // RegisterCycleClientHotkey(this._configuration.CycleGroup1BackwardHotkeys?.Select(x => this._configuration.StringToKey(x)), false, this._configuration.CycleGroup1ClientsOrder);
//
RegisterCycleClientHotkey(this._configuration.CycleGroup2ForwardHotkeys?.Select(x => this._configuration.StringToKey(x)), true, this._configuration.CycleGroup2ClientsOrder); // RegisterCycleClientHotkey(this._configuration.CycleGroup2ForwardHotkeys?.Select(x => this._configuration.StringToKey(x)), true, this._configuration.CycleGroup2ClientsOrder);
RegisterCycleClientHotkey(this._configuration.CycleGroup2BackwardHotkeys?.Select(x => this._configuration.StringToKey(x)), false, this._configuration.CycleGroup2ClientsOrder); // RegisterCycleClientHotkey(this._configuration.CycleGroup2BackwardHotkeys?.Select(x => this._configuration.StringToKey(x)), false, this._configuration.CycleGroup2ClientsOrder);
//
RegisterCycleClientHotkey(this._configuration.CycleGroup3ForwardHotkeys?.Select(x => this._configuration.StringToKey(x)), true, this._configuration.CycleGroup3ClientsOrder); // RegisterCycleClientHotkey(this._configuration.CycleGroup3ForwardHotkeys?.Select(x => this._configuration.StringToKey(x)), true, this._configuration.CycleGroup3ClientsOrder);
RegisterCycleClientHotkey(this._configuration.CycleGroup3BackwardHotkeys?.Select(x => this._configuration.StringToKey(x)), false, this._configuration.CycleGroup3ClientsOrder); // RegisterCycleClientHotkey(this._configuration.CycleGroup3BackwardHotkeys?.Select(x => this._configuration.StringToKey(x)), false, this._configuration.CycleGroup3ClientsOrder);
//
RegisterCycleClientHotkey(this._configuration.CycleGroup4ForwardHotkeys?.Select(x => this._configuration.StringToKey(x)), true, this._configuration.CycleGroup4ClientsOrder); // RegisterCycleClientHotkey(this._configuration.CycleGroup4ForwardHotkeys?.Select(x => this._configuration.StringToKey(x)), true, this._configuration.CycleGroup4ClientsOrder);
RegisterCycleClientHotkey(this._configuration.CycleGroup4BackwardHotkeys?.Select(x => this._configuration.StringToKey(x)), false, this._configuration.CycleGroup4ClientsOrder); // RegisterCycleClientHotkey(this._configuration.CycleGroup4BackwardHotkeys?.Select(x => this._configuration.StringToKey(x)), false, this._configuration.CycleGroup4ClientsOrder);
//
RegisterCycleClientHotkey(this._configuration.CycleGroup5ForwardHotkeys?.Select(x => this._configuration.StringToKey(x)), true, this._configuration.CycleGroup5ClientsOrder); // RegisterCycleClientHotkey(this._configuration.CycleGroup5ForwardHotkeys?.Select(x => this._configuration.StringToKey(x)), true, this._configuration.CycleGroup5ClientsOrder);
RegisterCycleClientHotkey(this._configuration.CycleGroup5BackwardHotkeys?.Select(x => this._configuration.StringToKey(x)), false, this._configuration.CycleGroup5ClientsOrder); // RegisterCycleClientHotkey(this._configuration.CycleGroup5BackwardHotkeys?.Select(x => this._configuration.StringToKey(x)), false, this._configuration.CycleGroup5ClientsOrder);
//
// Setup toggle tracking hotkey (Ctrl+T) // Setup toggle tracking hotkey (Ctrl+T)
var mainHandle = this._processMonitor.GetMainProcess().Handle; var mainHandle = this._processMonitor.GetMainProcess().Handle;
System.Diagnostics.Debug.WriteLine($"Registering hotkey with main window handle: {mainHandle}"); System.Diagnostics.Debug.WriteLine($"Registering hotkey with main window handle: {mainHandle}");
this._toggleTrackingHotkey = new HotkeyHandler(mainHandle, Keys.Control | Keys.T); this._toggleTrackingHotkey = new HotkeyHandler(mainHandle, Keys.Control | Keys.F16);
this._toggleTrackingHotkey.Pressed += (object s, HandledEventArgs e) => this._toggleTrackingHotkey.Pressed += (object s, HandledEventArgs e) =>
{ {
System.Diagnostics.Debug.WriteLine("Hotkey handler triggered!");
if (!Control.IsKeyLocked(Keys.Scroll))
{
System.Diagnostics.Debug.WriteLine("Scroll lock is off, passing through");
e.Handled = false;
return;
}
var foregroundHandle = this._windowManager.GetForegroundWindowHandle(); var foregroundHandle = this._windowManager.GetForegroundWindowHandle();
if (foregroundHandle != IntPtr.Zero) if (foregroundHandle != IntPtr.Zero)
{ {
uint processId; uint processId;
GetWindowThreadProcessId(foregroundHandle, out processId); GetWindowThreadProcessId(foregroundHandle, out processId);
var process = Process.GetProcessById((int)processId); var process = Process.GetProcessById((int)processId);
if (process != null) if (process != null)
{ {
System.Diagnostics.Debug.WriteLine($"Found process: {process.ProcessName}"); System.Diagnostics.Debug.WriteLine($"Found process: {process.ProcessName}");
@@ -176,7 +168,7 @@ namespace EveOPreview.Services
IOrderedEnumerable<KeyValuePair<string, int>> clientOrder; IOrderedEnumerable<KeyValuePair<string, int>> clientOrder;
Dictionary<string, int> _cycleOrder = new Dictionary<string, int>(cycleOrder); Dictionary<string, int> _cycleOrder = new Dictionary<string, int>(cycleOrder);
if ( _cycleOrder.Count == 0 ) if ( _cycleOrder.Count == 0 )
{ {
int order = 0; int order = 0;
foreach( var x in _thumbnailViews) foreach( var x in _thumbnailViews)
@@ -246,7 +238,7 @@ namespace EveOPreview.Services
if (_thumbnailViews.Any(x => x.Value.Title == t.Key)) if (_thumbnailViews.Any(x => x.Value.Title == t.Key))
{ {
var ptr = t.Key.Equals("EVE") ? var ptr = t.Key.Equals("EVE") ?
(isForwards ? _thumbnailViews.OrderBy(x => x.Value.Id.ToInt64()) : _thumbnailViews.OrderByDescending(x => x.Value.Id.ToInt64())).First(x => x.Value.Title == t.Key) (isForwards ? _thumbnailViews.OrderBy(x => x.Value.Id.ToInt64()) : _thumbnailViews.OrderByDescending(x => x.Value.Id.ToInt64())).First(x => x.Value.Title == t.Key)
: _thumbnailViews.First(x => x.Value.Title == t.Key); : _thumbnailViews.First(x => x.Value.Title == t.Key);
SetActive(ptr); SetActive(ptr);
@@ -547,7 +539,7 @@ namespace EveOPreview.Services
view.IsOverlayEnabled = this._configuration.ShowThumbnailOverlays; view.IsOverlayEnabled = this._configuration.ShowThumbnailOverlays;
view.SetHighlight( view.SetHighlight(
this._configuration.EnableActiveClientHighlight && (view.Id == this._activeClient.Handle), this._configuration.EnableActiveClientHighlight && (view.Id == this._activeClient.Handle),
this._configuration.ActiveClientHighlightThickness); this._configuration.ActiveClientHighlightThickness);
if (!view.IsActive) if (!view.IsActive)