Ask general questions here.
- Posts: 367
- Joined: Tue Aug 10, 2010 3:23 pm
- Location: Toronto, Ontario, Canada
How do I find the window (form) that is in the foreground and has input focus without knowing what it is?
I tried this but it didn't seem to work:
Dim MyForm as Ranorex.Form
Adapter.DefaultSearchTimeout = 30000
MyForm = "//form[@hasfocus='true']"
- Ranorex Guru
- Posts: 1335
- Joined: Thu Oct 16, 2008 6:46 pm
- Location: Arizona, USA
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!
- Site Admin
- Posts: 12016
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
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: