From 004cf3d8ab4e32d7b5966265eb0f65efc562ad28 Mon Sep 17 00:00:00 2001 From: hawkeye Date: Sun, 10 Sep 2023 12:19:41 -0400 Subject: [PATCH] Attempt to fix pop out issue --- DomainModel/DomainModel.csproj | 6 +++--- MainApp/MainApp.csproj | 6 +++--- Orchestration/MainOrchestrator.cs | 3 +++ Orchestration/Orchestration.csproj | 6 +++--- Orchestration/PanelPopOutOrchestrator.cs | 12 +++++++----- Shared/Shared.csproj | 6 +++--- SimconnectAgent/SimconnectAgent.csproj | 6 +++--- WindowsAgent/InputEmulationManager.cs | 20 ++++++++++++-------- WindowsAgent/WindowsAgent.csproj | 6 +++--- 9 files changed, 40 insertions(+), 31 deletions(-) diff --git a/DomainModel/DomainModel.csproj b/DomainModel/DomainModel.csproj index 39d308e..91b48d1 100644 --- a/DomainModel/DomainModel.csproj +++ b/DomainModel/DomainModel.csproj @@ -11,9 +11,9 @@ https://github.com/hawkeye-stan/msfs-popout-panel-manager MSFSPopoutPanelManager.DomainModel x64 - 4.0.2.8 - 4.0.2.8 - 4.0.2.8 + 4.0.2.9 + 4.0.2.9 + 4.0.2.9 win-x64 Embedded Debug;Release;Local diff --git a/MainApp/MainApp.csproj b/MainApp/MainApp.csproj index 3e71f46..8603042 100644 --- a/MainApp/MainApp.csproj +++ b/MainApp/MainApp.csproj @@ -14,9 +14,9 @@ MSFSPopoutPanelManager.MainApp logo.ico x64 - 4.0.2.8 - 4.0.2.8 - 4.0.2.8 + 4.0.2.9 + 4.0.2.9 + 4.0.2.9 embedded en diff --git a/Orchestration/MainOrchestrator.cs b/Orchestration/MainOrchestrator.cs index bf17a3b..4e21156 100644 --- a/Orchestration/MainOrchestrator.cs +++ b/Orchestration/MainOrchestrator.cs @@ -38,6 +38,9 @@ namespace MSFSPopoutPanelManager.Orchestration FlightSim.OnSimulatorExited += (sender, e) => { ApplicationClose(); Environment.Exit(0); }; Keyboard.PanelPopOutOrchestrator = PanelPopOut; + + // Delete all existing cache version of app + Help.DeleteAppCache(); } public ProfileOrchestrator Profile { get; set; } diff --git a/Orchestration/Orchestration.csproj b/Orchestration/Orchestration.csproj index f28b069..68a85ff 100644 --- a/Orchestration/Orchestration.csproj +++ b/Orchestration/Orchestration.csproj @@ -11,9 +11,9 @@ https://github.com/hawkeye-stan/msfs-popout-panel-manager MSFSPopoutPanelManager.Orchestration x64 - 4.0.2.8 - 4.0.2.8 - 4.0.2.8 + 4.0.2.9 + 4.0.2.9 + 4.0.2.9 win-x64 Embedded Debug;Release;Local diff --git a/Orchestration/PanelPopOutOrchestrator.cs b/Orchestration/PanelPopOutOrchestrator.cs index eb013d6..3fe9288 100644 --- a/Orchestration/PanelPopOutOrchestrator.cs +++ b/Orchestration/PanelPopOutOrchestrator.cs @@ -249,9 +249,7 @@ namespace MSFSPopoutPanelManager.Orchestration WorkflowStepWithMessage.Execute(panelConfig.PanelName, () => { panelConfig.IsSelectedPanelSource = true; - PanelSourceOrchestrator.ShowPanelSourceNonEdit(panelConfig); ExecuteCustomPopout(panelConfig, builtInPanelHandles, index++); - PanelSourceOrchestrator.ClosePanelSourceNonEdit(panelConfig); ApplyPanelLocation(panelConfig); panelConfig.IsSelectedPanelSource = false; @@ -434,6 +432,10 @@ namespace MSFSPopoutPanelManager.Orchestration { if (panel.PanelType == PanelType.CustomPopout) { + PanelSourceOrchestrator.ShowPanelSourceNonEdit(panel); + InputEmulationManager.PrepareToPopOutPanel((int)panel.PanelSource.X, (int)panel.PanelSource.Y); + PanelSourceOrchestrator.ClosePanelSourceNonEdit(panel); + // There should only be one handle that is not in both builtInPanelHandles vs latestAceAppWindowsWithCaptionHandles var handle = TryPopOutCustomPanel(panel.PanelSource, builtInPanelHandles); @@ -467,7 +469,7 @@ namespace MSFSPopoutPanelManager.Orchestration private IntPtr TryPopOutCustomPanel(PanelSource panelSource, List builtInPanelHandles) { - // Try to pop out 5 times before failure with 1/4 second wait in between + // Try to pop out 3 times before failure with 1/2 second wait in between int count = 0; do { @@ -481,10 +483,10 @@ namespace MSFSPopoutPanelManager.Orchestration if (handle != IntPtr.Zero) return handle; - Thread.Sleep(250); + Thread.Sleep(500); count++; } - while (count < 5); + while (count < 3); return IntPtr.Zero; } diff --git a/Shared/Shared.csproj b/Shared/Shared.csproj index 69db2b6..04e9530 100644 --- a/Shared/Shared.csproj +++ b/Shared/Shared.csproj @@ -11,9 +11,9 @@ https://github.com/hawkeye-stan/msfs-popout-panel-manager MSFSPopoutPanelManager.Shared x64 - 4.0.2.8 - 4.0.2.8 - 4.0.2.8 + 4.0.2.9 + 4.0.2.9 + 4.0.2.9 win-x64 Embedded Debug;Release;Local diff --git a/SimconnectAgent/SimconnectAgent.csproj b/SimconnectAgent/SimconnectAgent.csproj index e8a0880..9a44020 100644 --- a/SimconnectAgent/SimconnectAgent.csproj +++ b/SimconnectAgent/SimconnectAgent.csproj @@ -11,9 +11,9 @@ https://github.com/hawkeye-stan/msfs-popout-panel-manager MSFSPopoutPanelManager.SimConnectAgent x64 - 4.0.2.8 - 4.0.2.8 - 4.0.2.8 + 4.0.2.9 + 4.0.2.9 + 4.0.2.9 win-x64 Embedded Debug;Release;Local diff --git a/WindowsAgent/InputEmulationManager.cs b/WindowsAgent/InputEmulationManager.cs index 0093903..78465bb 100644 --- a/WindowsAgent/InputEmulationManager.cs +++ b/WindowsAgent/InputEmulationManager.cs @@ -44,25 +44,28 @@ namespace MSFSPopoutPanelManager.WindowsAgent PInvoke.mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0); } - public static void PopOutPanel(int x, int y, bool useSecondaryKeys) + public static void PrepareToPopOutPanel(int x, int y) { - Debug.WriteLine($"Pop out panel at: {x}/{y} ..."); - PInvoke.SetForegroundWindow(WindowProcessManager.SimulatorProcess.Handle); Thread.Sleep(250); MoveAppWindowFromLeftClickPoint(x, y); - LeftClick(x, y); + // Left click outside the cirlce area to focus game window + LeftClick(x + 30, y); - // Force cursor reset and focus (doubling to make sure) - LeftClick(x, y); + // Force cursor reset and focus + PInvoke.SetCursorPos(x, y); + Thread.Sleep(500); + } + public static void PopOutPanel(int x, int y, bool useSecondaryKeys) + { if (useSecondaryKeys) { InputSimulator.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.LCONTROL); InputSimulator.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.RCONTROL); - Thread.Sleep(300); + Thread.Sleep(500); PInvoke.mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0); Thread.Sleep(200); PInvoke.mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0); @@ -79,7 +82,7 @@ namespace MSFSPopoutPanelManager.WindowsAgent else { InputSimulator.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.RMENU); - Thread.Sleep(300); + Thread.Sleep(500); PInvoke.mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0); Thread.Sleep(200); PInvoke.mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0); @@ -220,6 +223,7 @@ namespace MSFSPopoutPanelManager.WindowsAgent { var top = y - applicationRectangle.Height - 50; WindowActionManager.MoveWindow(appHandle, applicationRectangle.X, top, applicationRectangle.Width, applicationRectangle.Height); + Thread.Sleep(1000); } } diff --git a/WindowsAgent/WindowsAgent.csproj b/WindowsAgent/WindowsAgent.csproj index af0beac..8060fbe 100644 --- a/WindowsAgent/WindowsAgent.csproj +++ b/WindowsAgent/WindowsAgent.csproj @@ -11,9 +11,9 @@ https://github.com/hawkeye-stan/msfs-popout-panel-manager MSFSPopoutPanelManager.WindowsAgent x64 - 4.0.2.8 - 4.0.2.8 - 4.0.2.8 + 4.0.2.9 + 4.0.2.9 + 4.0.2.9 win-x64 Embedded Debug;Release;Local