/// <summary> /// Gets the main window of the application's process /// </summary> public Window GetMainWindow(AutomationBase automation) { var mainWindow = automation.FromHandle(MainWindowHandle).AsWindow(); if (mainWindow != null) { mainWindow.IsMainWindow = true; } return(mainWindow); }
/// <summary> /// Gets the main window of the application's process /// </summary> /// <param name="automation">The automation object to use.</param> /// <param name="waitTimeout">An optional timeout. If null is passed, the timeout is infinite.</param> /// <returns>The main window object as <see cref="Window" /> or null if no main window was found within the timeout.</returns> public Window GetMainWindow(AutomationBase automation, TimeSpan?waitTimeout = null) { WaitWhileMainHandleIsMissing(waitTimeout); var mainWindowHandle = MainWindowHandle; if (mainWindowHandle == IntPtr.Zero) { return(null); } var mainWindow = automation.FromHandle(mainWindowHandle).AsWindow(); if (mainWindow != null) { mainWindow.IsMainWindow = true; } return(mainWindow); }
public Window GetMainWindow(AutomationBase automation) { return(automation.FromHandle(MainWindowHandle).AsWindow()); }