Ask general questions here.
-
Aracknid
- Posts: 375
- Joined: Tue Aug 10, 2010 3:23 pm
- Location: Toronto, Ontario, Canada
Post
by Aracknid » Mon Jul 11, 2011 9:07 pm
How do I find the window (form) that is in the foreground and has input focus without knowing what it is?
What I'm trying to do is take a screen shot of the window in the foreground when something unexpected has happend. So say I'm in IE and I get an unexpected IE dialog appear that has a javascript error and details... but it could also be any other dialog. And it could be from any other app, not IE.
I tried this but it didn't seem to work:
Dim MyForm as Ranorex.Form
Adapter.DefaultSearchTimeout = 30000
MyForm = "//form[@hasfocus='true']"
Thanks,
Aracknid
-
Ciege
- Ranorex Guru
- Posts: 1335
- Joined: Thu Oct 16, 2008 6:46 pm
- Location: Arizona, USA
Post
by Ciege » Mon Jul 11, 2011 9:52 pm
Two things I can think of quickly.
1)You can just take a screenshot of the entire desktop:
2) You can get an iList of Form objects that are children of the desktop, then iterate those objects checking the HasFocus property of each.
There is probably a better way to do it, but those are 2 quick ways that I could come up with.
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...
-
Support Team
- Site Admin

- Posts: 12174
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
-
Contact:
Post
by Support Team » Mon Jul 11, 2011 10:16 pm
Aracknid wrote:How do I find the window (form) that is in the foreground and has input focus without knowing what it is?
The Form adapter has the
Active property that is "true" for the currently active form. Consequently, the following RanoreXPath will get you the currently active form:
Regards,
Alex
Ranorex Team