/// <summary> /// Resizes the window /// </summary> /// <param name="windowHandle">NativeWindowHandle to window</param> /// <param name="width">The new width of the window, in pixels</param> /// <param name="height">The new height of the window, in pixels</param> /// <exception cref="ProdOperationException">Examine inner exception</exception> public static void WindowResize(IntPtr windowHandle, double width, double height) { try { int ret = TransformPatternHelper.Resize(AutomationElement.FromHandle(windowHandle), width, height); if (ret != -1) { return; } double x = AutomationElement.FromHandle(windowHandle).Current.BoundingRectangle.X; double y = AutomationElement.FromHandle(windowHandle).Current.BoundingRectangle.Y; ProdWindowNative.MoveWindowNative(windowHandle, x, y, width, height); } catch (InvalidOperationException err) { throw new ProdOperationException(err.Message, err); } catch (ElementNotAvailableException err) { throw new ProdOperationException(err.Message, err); } catch (ArgumentException err) { throw new ProdOperationException(err.Message, err); } }
/// <summary> /// Minimizes the current window /// </summary> /// <param name="windowHandle">NativeWindowHandle to window</param> /// <exception cref="ProdOperationException">Examine inner exception</exception> public static void WindowMinimize(IntPtr windowHandle) { try { WindowPatternHelper.SetVisualState(AutomationElement.FromHandle(windowHandle), WindowVisualState.Minimized); } catch (InvalidOperationException) { ProdWindowNative.MinimizeWindowNative(windowHandle); } catch (ElementNotAvailableException err) { throw new ProdOperationException(err.Message, err); } catch (ArgumentException err) { throw new ProdOperationException(err.Message, err); } catch (Win32Exception werr) { throw new ProdOperationException(werr.Message, werr); } }
/// <summary> /// Sets the specified windows title /// </summary> /// <param name="windowHandle">NativeWindowHandle to window</param> /// <param name="newText">The text to set the title to</param> /// <exception cref="ProdOperationException">Examine inner exception</exception> public static void WindowSetTitle(IntPtr windowHandle, string newText) { try { ProdWindowNative.SetWindowTitleNative(windowHandle, newText); } catch (InvalidOperationException err) { throw new ProdOperationException(err.Message, err); } catch (ElementNotAvailableException err) { throw new ProdOperationException(err.Message, err); } catch (ArgumentException err) { throw new ProdOperationException(err.Message, err); } catch (Win32Exception werr) { throw new ProdOperationException(werr.Message, werr); } }
/// <summary> /// Gets the specified windows title /// </summary> /// <param name="windowHandle">NativeWindowHandle to target window</param> /// <returns> /// The specified Windows Title /// </returns> /// <exception cref="ProdOperationException">Examine inner exception</exception> public static string WindowGetTitle(IntPtr windowHandle) { try { return(ProdWindowNative.GetWindowTitleNative(windowHandle)); } catch (InvalidOperationException err) { throw new ProdOperationException(err.Message, err); } catch (ElementNotAvailableException err) { throw new ProdOperationException(err.Message, err); } catch (ArgumentException err) { throw new ProdOperationException(err.Message, err); } catch (Win32Exception werr) { throw new ProdOperationException(werr.Message, werr); } }