Close forms

Ask general questions here.
marcushe
Posts: 112
Joined: Tue Apr 14, 2009 6:38 am

Close forms

Post by marcushe » Thu Jul 09, 2009 9:08 am

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????

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Close forms

Post by Ciege » Thu Jul 09, 2009 4:03 pm

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.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Close forms

Post by Support Team » Thu Jul 09, 2009 4:13 pm

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

marcushe
Posts: 112
Joined: Tue Apr 14, 2009 6:38 am

Re: Close forms

Post by marcushe » Fri Jul 10, 2009 3:17 am

Thanks , it's a easy way to identify forms.