Page 1 of 1

Close forms

Posted: Thu Jul 09, 2009 9:08 am
by marcushe
Environment:Ranorex 2.1,Win7
Target:
before my project is running ,i must close all casual forms ,as some popup, some applications which is shown under special conditions.
Use Host.Local.Children , i can get all forms by compressing conditions ,like title must be "form:xxx"
But how can i identify these forms? I think below condition can determin the forms that should be closed.
1. Visible,Enabled,Valid=True
2. Width,Height<Screen width,Height
3. Must has Close button at upper right
4. Has controls
5. process name <> explorer.exe ,sidebar
How can i know it has Close(X) button????

Re: Close forms

Posted: Thu Jul 09, 2009 4:03 pm
by Ciege
marcushe wrote: How can i know it has Close(X) button????
You can use Spy to verify this, but the title bar of each form/window should have a push button named "Close" that represents the X. Similarly it may have a Minimize & Maximize push button as well.

Re: Close forms

Posted: Thu Jul 09, 2009 4:13 pm
by Support Team
Hi marcushe,
you can use the RanorexPath to get a list with all forms which have a close button in their titlebar:
foreach(Ranorex.Form form in Host.Local.Find<Ranorex.Form>("/form/titlebar/button[@accessiblename='Close']/../../"))
{           	
     if(form.Visible && form.Enabled /*..whatever...*/)
     {
       form.Close();
     }
}
Regards,
Christian
Ranorex Support Team

Re: Close forms

Posted: Fri Jul 10, 2009 3:17 am
by marcushe
Thanks , it's a easy way to identify forms.