Micro Focus QTP (UFT) Forums
Output an object that currently has "focus" on the form - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: Output an object that currently has "focus" on the form (/Thread-Output-an-object-that-currently-has-focus-on-the-form)



Output an object that currently has "focus" on the form - D2010 - 08-02-2010

I am using a customer defined dot.net application. My “code” currently looks similar to this:

Code:
SwfWindow(“MyProgram”).SwfWindow(“MyForm”).SwfEdit(“txtDisplayedValue_33”).Click
SwfWindow(“MyProgram”).SwfWindow(“MyForm”).SwfEdit(“txtDisplayedValue_33”).Type micDwn

So it clicks a text field (which I know exists and know the naming of) and then presses the down key. I plan to put the down method in a loop so that it will keep going down till it finds an empty cell.

My problem is that the naming of the fields are not consistent. As you can see I am starting on text field 33, but the next text field could be 34 or 134 as it varies on each form. But I do know that if I press the down key it will move to the text field that I require, as the text fields are laid out in a column.

I need to know how to output to QTP what current field has “focus” – I will then use this field to see if it is “empty”, if not, I will click down to the next field and repeat the process till I find the first empty text field in the list. Like I said previously, this does not follow logical number all of the time but I do know it will have the mouse curser in the field as it will be “focused”.

Is it possible to output what object in the form currently has the focus – and if so, how would I go about writing this?

Thanks for any help in this matter.


RE: Output an object that currently has "focus" on the form - D2010 - 08-04-2010

Just for Information for others, I found the solution from another forum. The solution was to use Descriptive Programming and to define the required object as having the property of "focused" as "True". I can then use GetROProperty("value") to output the current value of the field that has focus.