From c675e359fb98d2ecf8b7820f154e519584d608df Mon Sep 17 00:00:00 2001 From: Jared Date: Tue, 13 Apr 2021 21:11:32 -0700 Subject: [PATCH] Send input on STA thread. --- Desktop.Win/Services/KeyboardMouseInputWin.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Desktop.Win/Services/KeyboardMouseInputWin.cs b/Desktop.Win/Services/KeyboardMouseInputWin.cs index fb3465ea..0ecdbbe4 100644 --- a/Desktop.Win/Services/KeyboardMouseInputWin.cs +++ b/Desktop.Win/Services/KeyboardMouseInputWin.cs @@ -344,11 +344,13 @@ namespace Remotely.Desktop.Win.Services { if (!_inputBlocked) { - if (!Win32Interop.SwitchToInputDesktop()) + var inputThread = new Thread(() => { - Logger.Write("Desktop switch failed while sending input."); - } - inputAction(); + Win32Interop.SwitchToInputDesktop(); + inputAction(); + }); + inputThread.SetApartmentState(ApartmentState.STA); + inputThread.Start(); } else {