How to minimize or Maximize application

Aug 11, 2008 at 8:47 AM
Hi 
 
    I am very new to White Framework. Can someone let me know how to Minimize or Maximize application. I am able to focus on to a application which i need. Do we have an option to Maximize the existing application from the taskbar.
   

 

Window window = application.GetWindow("Dashboard", InitializeOption.NoCache);
window.Focus;


Thanks
Bagya

 

Aug 11, 2008 at 9:36 AM
Edited Aug 11, 2008 at 9:38 AM
I don`t know if white UiItem classes support this, but for sure AutomationElement does it,
every window in tree of AutomationElement has Minimize, Maximize and Close Automation Elements, which can be "invoked"
if you will use following snippet :

        protected void Discover(AutomationElement automationParent)
        {
            Console.WriteLine("ROOT: " + automationParent.Current.AutomationId + " " + automationParent.Current.ClassName);

            foreach (var pattern in automationParent.GetSupportedPatterns())
            {
                Console.WriteLine(" " + pattern.ProgrammaticName);
            }

            foreach (var item in automationParent.FindAll(TreeScope.Descendants, Condition.TrueCondition))
            {
                var itemStrong = item as AutomationElement;
                if (itemStrong == null)
                {
                    Console.WriteLine(" !! Not RESOLVED : " + item.GetType().FullName);
                    continue;
                }
                object itemObject = null;
                var message = itemStrong.Current.AutomationId+"("+itemStrong.Current.Name+")" + " ";
                if(itemObject != null) message += itemObject.GetType().BaseType.FullName;
                Console.WriteLine(message);
                foreach (var pattern in itemStrong.GetSupportedPatterns())
                {
                    Console.WriteLine(" " + pattern.ProgrammaticName);
                }
            }
        }


and use it with main window's AutomationElement property, you will see folowing results :
ROOT:  Window
 WindowPatternIdentifiers.Pattern
 TransformPatternIdentifiers.Pattern
TitleBar(ASDASD)
SystemMenuBar(System Menu Bar)
Item 1(System)
 ExpandCollapsePatternIdentifiers.Pattern
Minimize(Minimize)
 InvokePatternIdentifiers.Pattern
Restore(Restore)
 InvokePatternIdentifiers.Pattern
Close(Close)
 InvokePatternIdentifiers.Pattern
()


As you can see, there is a "Minimize", "Restore", "Close" AutomationElements, which can be invoked manually...
Coordinator
Aug 11, 2008 at 7:46 PM
You need to do something like this.
window.DisplayState = Core.UIItems.WindowItems.DisplayState.Minimized;
window.DisplayState = Core.UIItems.WindowItems.DisplayState.Minimized;
etc.
Aug 12, 2008 at 5:56 PM
You can also get to the TitleBar of the window and press the buttons.

window.TitleBar.MaximizeButton.Click();


Mar 19, 2010 at 9:55 AM
Edited Mar 19, 2010 at 10:00 AM

// the following doesn't work if the window is minimized, since TitleBar and MaximizeButton are not visible

window.TitleBar.MaximizeButton.Click();

// the workaround is:

window.DisplayState = Core.UIItems.WindowItems.DisplayState.Restored;

// or

window.DisplayState = Core.UIItems.WindowItems.DisplayState.Maximized;

// I believe controlling window state via direct setting DisplayState property is a bit weird, though

Mar 19, 2010 at 10:07 AM

Hi

 

i have written a slow function :)

 

/// <summary>
/// Changes the display.
/// </summary>
/// <param name="state">The state.</param>
public static void ChangeDisplayState( DisplayState state )
{
  if( MainWindow.DisplayState != state )
  {
	MainWindow.DisplayState = state;
  }
}

is the same as above but you should take care that you don't use a state which already is set.