private static int GetIntervalMilliseconds(FixerStatus results) { if (results.FindWindowResult == null) { return(IntervalSecsWatchingForWindow * 1000); } return(results.FindWindowResult.JwlRunning ? IntervalSecsWatchingForProcess * 1000 : IntervalSecsWatchingForWindow * 1000); }
public string Generate(FixerStatus results, string appName) { string result; if (results.ErrorIsTransitioning) { result = $"{appName} is transitioning."; } else if (results.ErrorUnknown) { result = "Unknown error."; } else if (!results.FindWindowResult.JwlRunning) { result = $"{appName} is not running."; } else if (!results.FindWindowResult.FoundMediaWindow) { result = $"Could not find {appName} media window."; } else if (results.FindWindowResult.IsAlreadyFixed) { result = $"Found {appName} media window. Already fixed."; } else if (results.IsFixed) { result = $"Found {appName} media window and fixed it."; } else if (!results.CoreWindowFocused) { result = "Could not fix - core window not focused."; } else { result = "Could not fix - core window focused."; } if (result.Equals(_previousMessage)) { return(null); } _previousMessage = result; return(result); }
public string Generate(FixerStatus results, string appName) { string result; if (results.ErrorIsTransitioning) { result = $"{appName} in transizione."; } else if (results.ErrorUnknown) { result = "Errore sconosciuto."; } else if (!results.FindWindowResult.JwlRunning) { result = $"{appName} non è in esecuzione."; } else if (!results.FindWindowResult.FoundMediaWindow) { result = $"Impossibile trovare finestra multimediale di {appName}."; } else if (results.FindWindowResult.IsAlreadyFixed) { result = $"Trovata finestra multimediale di {appName}. Già corretta."; } else if (results.IsFixed) { result = $"Trovata e corretta finestra multimediale di {appName}."; } else if (!results.CoreWindowFocused) { result = "Impossibile correggere – finestra principale non focalizzata."; } else { result = "Impossibile correggere – finestra principale focalizzata."; } if (result.Equals(_previousMessage)) { return(null); } _previousMessage = result; return(result); }
public ProgressEventArgs(FixerStatus st, string info) { this.StrInfo = info; this.State = st; }
private void SendStatusEvent(FixerStatus results) { StatusEvent?.Invoke(this, new FixerStatusEventArgs { Status = results }); }
private FixerStatus ExecuteInternal( JwLibAppTypes appType, bool topMost, string processName, string caption) { var result = new FixerStatus { FindWindowResult = GetMediaAndCoreWindow(appType, processName, caption) }; if (!result.FindWindowResult.FoundMediaWindow || result.FindWindowResult.IsAlreadyFixed) { return(result); } var mainHandle = (IntPtr)result.FindWindowResult.MainMediaWindow.Current.NativeWindowHandle; var coreHandle = (IntPtr)result.FindWindowResult.CoreMediaWindow.Current.NativeWindowHandle; // this Sleep is probably not needed Thread.Sleep(1000); NativeMethods.SetForegroundWindow(coreHandle); var rect = result.FindWindowResult.MainMediaWindow.Current.BoundingRectangle; result.FindWindowResult.CoreMediaWindow.SetFocus(); if (!result.FindWindowResult.CoreMediaWindow.Current.HasKeyboardFocus) { return(result); } result.CoreWindowFocused = true; // convert the window using Win+Shift+Return if (!ConvertMediaWindow(result.FindWindowResult.MainMediaWindow)) { return(result); } var insertAfterValue = topMost ? new IntPtr(-1) : new IntPtr(0); const uint ShowWindowFlag = 0x0040; const uint NoCopyBitsFlag = 0x0100; const uint NoSendChangingFlag = 0x0400; // the window used to have a non-transparent titlebar so we could // just remove it by trimming the top margin... // const int adjustment = 34; // adjustment for titlebar // const int border = 8; // adjustment for borders // ... but in Jan 2021 the title bar became transparent and so // it needed to be retained. However, the command buttons top right // can be 'removed' (see below) const int adjustment = 1; // adjustment for titlebar const int border = 8; // adjustment for borders // this Sleep is definitely required. Without it, the media window may remain // on the primary display (i.e. the SetWindowPos call is ineffective). See #5 Thread.Sleep(500); NativeMethods.SetWindowPos( mainHandle, insertAfterValue, (int)rect.Left - border, (int)rect.Top - adjustment, (int)rect.Width + (border * 2), (int)rect.Height + adjustment + border, (int)(NoCopyBitsFlag | NoSendChangingFlag | ShowWindowFlag)); result.IsFixed = true; EnsureWindowIsNonSizeable(mainHandle); // to 'remove' the command buttons from the transparent title bar // we move focus to the main JWL window and then disable the media // window meaning it can no longer gain focus via mouse click. This // doesn't prevent the button being displayed if you alt-tab to the // media window but it is a small change that is generally helpful. NativeMethods.SetForegroundWindow(coreHandle); NativeMethods.EnableWindow(mainHandle, false); return(result); }
private FixerStatus ExecuteInternal( JwLibAppTypes appType, bool topMost, string processName, string caption) { var result = new FixerStatus { FindWindowResult = GetMediaAndCoreWindow(appType, processName, caption) }; if (!result.FindWindowResult.FoundMediaWindow || result.FindWindowResult.IsAlreadyFixed) { return(result); } var mainHandle = (IntPtr)result.FindWindowResult.MainMediaWindow.Current.NativeWindowHandle; var coreHandle = (IntPtr)result.FindWindowResult.CoreMediaWindow.Current.NativeWindowHandle; // The Sleep is an attempt to fix #5 (where media window is shown on primary display). // My assumption is that the media window appears first on the same // display as JWL and is then moved to the secondary display, and the "rect = " // call below retrieves this initial position! Thread.Sleep(1000); NativeMethods.SetForegroundWindow(coreHandle); var rect = result.FindWindowResult.MainMediaWindow.Current.BoundingRectangle; result.FindWindowResult.CoreMediaWindow.SetFocus(); if (!result.FindWindowResult.CoreMediaWindow.Current.HasKeyboardFocus) { return(result); } result.CoreWindowFocused = true; // convert the window using Win+Shift+Return if (!ConvertMediaWindow(result.FindWindowResult.MainMediaWindow)) { return(result); } var insertAfterValue = topMost ? new IntPtr(-1) : new IntPtr(0); const uint ShowWindowFlag = 0x0040; const uint NoCopyBitsFlag = 0x0100; const uint NoSendChangingFlag = 0x0400; const int adjustment = 34; const int border = 8; NativeMethods.SetWindowPos( mainHandle, insertAfterValue, (int)rect.Left - border, (int)rect.Top - adjustment, (int)rect.Width + (border * 2), (int)rect.Height + adjustment + border, (int)(NoCopyBitsFlag | NoSendChangingFlag | ShowWindowFlag)); result.IsFixed = true; return(result); }
private FixerStatus ExecuteInternal( JwLibAppTypes appType, bool topMost, string processName, string caption) { var result = new FixerStatus { FindWindowResult = GetMediaAndCoreWindow(appType, processName, caption) }; if (!result.FindWindowResult.FoundMediaWindow || result.FindWindowResult.IsAlreadyFixed) { return(result); } var mainHandle = (IntPtr)result.FindWindowResult.MainMediaWindow.Current.NativeWindowHandle; var coreHandle = (IntPtr)result.FindWindowResult.CoreMediaWindow.Current.NativeWindowHandle; // this Sleep is probably not needed Thread.Sleep(1000); NativeMethods.SetForegroundWindow(coreHandle); var rect = result.FindWindowResult.MainMediaWindow.Current.BoundingRectangle; result.FindWindowResult.CoreMediaWindow.SetFocus(); if (!result.FindWindowResult.CoreMediaWindow.Current.HasKeyboardFocus) { return(result); } result.CoreWindowFocused = true; // convert the window using Win+Shift+Return if (!ConvertMediaWindow(result.FindWindowResult.MainMediaWindow)) { return(result); } var insertAfterValue = topMost ? new IntPtr(-1) : new IntPtr(0); const uint ShowWindowFlag = 0x0040; const uint NoCopyBitsFlag = 0x0100; const uint NoSendChangingFlag = 0x0400; const int adjustment = 34; const int border = 8; // this Sleep is definitely required. Without it, the media window may remain // on the primary display (i.e. the SetWindowPos call is ineffective). See #5 Thread.Sleep(500); NativeMethods.SetWindowPos( mainHandle, insertAfterValue, (int)rect.Left - border, (int)rect.Top - adjustment, (int)rect.Width + (border * 2), (int)rect.Height + adjustment + border, (int)(NoCopyBitsFlag | NoSendChangingFlag | ShowWindowFlag)); result.IsFixed = true; return(result); }