Best practices, code snippets for common functionality, examples, and guidelines.
-
BCTest
- Posts: 127
- Joined: Tue Jun 03, 2014 10:15 am
- Location: Hamburg, Germany
Post
by BCTest » Tue Jan 26, 2016 10:22 am
I found this simple code in
this forum to access the currently activated window:
//Search for the active foreground window and checks if "active" state is true
Ranorex.Form myActiveForm = Host.Local.FindSingle("/form[@active='True']");
Is it possible to access the currently focused control in this Form?
It could be a button, an edit-control, a combobox or whatever...
Regards,
Thomas
-
odklizec
- Ranorex Guru
- Posts: 7470
- Joined: Mon Aug 13, 2012 9:54 am
- Location: Zilina, Slovakia
Post
by odklizec » Tue Jan 26, 2016 10:49 am
Hi,
Try something like this...
Ranorex.Form myActiveForm = Host.Local.FindSingle("/form[@active='True']/*[@accessiblestate~'Focused']");
This should return first focused element on active form.
Pavel Kudrys
Ranorex explorer at
Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
-
BCTest
- Posts: 127
- Joined: Tue Jun 03, 2014 10:15 am
- Location: Hamburg, Germany
Post
by BCTest » Tue Jan 26, 2016 11:44 am
odklizec wrote:Hi,
Try something like this...
Ranorex.Form myActiveForm = Host.Local.FindSingle("/form[@active='True']/*[@accessiblestate~'Focused']");
This should return first focused element on active form.
Hello odklizec,
Thanks for your fast and proper answer: exactly what I want!
Ranorex.Core.Element activeElement = Host.Local.FindSingle("/form[@active='True']/*[@accessiblestate~'Focused']");
Regards,
Thomas
-
odklizec
- Ranorex Guru
- Posts: 7470
- Joined: Mon Aug 13, 2012 9:54 am
- Location: Zilina, Slovakia
Post
by odklizec » Tue Jan 26, 2016 12:30 pm
Cool. I'm glad I could help
Pavel Kudrys
Ranorex explorer at
Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration