# HG changeset patch # User StephaneLenclud # Date 1426756676 -3600 # Node ID c8d81bfa5fff007dbaf9bfe2305ac4dd65fa06ab # Parent 9d5867ce966a54ca19ea40ba503fb1e2f57a17fa Trying yet another function to bring to foreground but it's broken too. diff -r 9d5867ce966a -r c8d81bfa5fff Server/MainForm.Hid.cs --- a/Server/MainForm.Hid.cs Wed Mar 18 21:47:06 2015 +0100 +++ b/Server/MainForm.Hid.cs Thu Mar 19 10:17:56 2015 +0100 @@ -33,6 +33,8 @@ [return: System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] public static extern bool AttachThreadInput(uint idAttach, uint idAttachTo, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] bool fAttach); + [System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "SwitchToThisWindow")] + public static extern void SwitchToThisWindow([System.Runtime.InteropServices.InAttribute()] System.IntPtr hwnd, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] bool fUnknown); // public delegate void OnHidEventDelegate(object aSender, Hid.Event aHidEvent); @@ -154,7 +156,8 @@ } else { - ForceForegroundWindow(existingProcesses[0].MainWindowHandle); + //ForceForegroundWindow(existingProcesses[0].MainWindowHandle); + SwitchToThisWindow(existingProcesses[0].MainWindowHandle, true); } } }