diff --git a/JL.Core/Network/WebSocketUtils.cs b/JL.Core/Network/WebSocketUtils.cs index 191c9bae..9f6e4d46 100644 --- a/JL.Core/Network/WebSocketUtils.cs +++ b/JL.Core/Network/WebSocketUtils.cs @@ -9,6 +9,7 @@ public static class WebSocketUtils { private static Task? s_webSocketTask = null; private static CancellationTokenSource? s_webSocketCancellationTokenSource = null; + public static bool Connected => !s_webSocketTask?.IsCompleted ?? false; public static void HandleWebSocket() { diff --git a/JL.Windows/GUI/MainWindow.xaml.cs b/JL.Windows/GUI/MainWindow.xaml.cs index f92cd82f..581e7f5d 100644 --- a/JL.Windows/GUI/MainWindow.xaml.cs +++ b/JL.Windows/GUI/MainWindow.xaml.cs @@ -720,15 +720,18 @@ public async Task HandleHotKey(KeyGesture keyGesture, KeyEventArgs? e) { handled = true; - CoreConfig.CaptureTextFromWebSocket = true; - - if (!StatsUtils.StatsStopWatch.IsRunning) + if (!WebSocketUtils.Connected) { - StatsUtils.StatsStopWatch.Start(); - StatsUtils.StartStatsTimer(); - } + CoreConfig.CaptureTextFromWebSocket = true; - WebSocketUtils.HandleWebSocket(); + if (!StatsUtils.StatsStopWatch.IsRunning) + { + StatsUtils.StatsStopWatch.Start(); + StatsUtils.StartStatsTimer(); + } + + WebSocketUtils.HandleWebSocket(); + } } else if (KeyGestureUtils.CompareKeyGestures(keyGesture, ConfigManager.TextBoxIsReadOnlyKeyGesture)) @@ -1452,7 +1455,8 @@ private void Window_StateChanged(object sender, EventArgs e) MainTextBox.Foreground = ConfigManager.MainWindowTextColor; } - if (ConfigManager.StopIncreasingTimeStatWhenMinimized) + if (ConfigManager.StopIncreasingTimeStatWhenMinimized + && (CoreConfig.CaptureTextFromClipboard || (CoreConfig.CaptureTextFromWebSocket && WebSocketUtils.Connected))) { StatsUtils.StatsStopWatch.Start(); }