FairfaxStu 0 Posted June 8, 2017 Posted June 8, 2017 I am trying to use a WMC remote to control MBT. I have managed to remap the green button to launch it successfully so now I am trying to handle the scenario where MBT is already running but not in foreground (the WMC remote attempts to control whatever is in the foreground). I am no expert in Windows Programming but I am using a simple PowerShell script as a wrapper and calls to setforegroundwindow are not working for MBT like they do for other Windows Applications I have tested with (e.g., notepad). My simple code is: # Imports Add-Type @" using System; using System.Runtime.InteropServices; public class Tricks { [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetForegroundWindow(IntPtr hWnd); } "@ # Get a window handle for MBT try { $hwnd = @(Get-Process Emby.Theater)[0].MainWindowHandle } catch { Write-Error "Failed to get active Window details. More Info: $_" } # If we got a handle, set it to foreground, else launch if ($hwnd) { [void] [Tricks]::SetForegroundWindow($hwnd) } else { & C:\Users\xxxxx\AppData\Roaming\Emby-Theater\system\Emby.Theater.exe } Is there any reason that setforegroundwindow should not work with MBT? The same code works fine with Notepad and Excel.
Luke 42078 Posted June 8, 2017 Posted June 8, 2017 Same reason as the taskbar pinning issue. The app has two windows. Once we get the taskbar pinning working again then I suspect this will resolve itself. Thanks.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now