Micro Focus QTP (UFT) Forums

Full Version: How to get the location(x,y) of an highlighted item in WinList
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

I have a WinList object and an item is highlighted by default.
I need to get the location of that highlighted item in WinList that can be in the form of x and y coordinates.

Input on this is appreciated.

sunny

Hi,
Use GetRoProperty to get the cordinates
---.GetRoProperty("x")
---.GetRoProperty("y")

Regards,
Sankalp
GetRoProperty("x") and GetRoProperty("y") gives the winlist box x and y coordinates.

I want the x and y coordinates for the highlighted item in the WinList, this highlighted item changes dynamically everytime

Sunny
You can use the following function to accomodate your requirement.

Code:
Public Sub ClickOnTextLocation()
        l = -1
    t = -1
    r = -1
    b = -1
    
    rtn = SwfWindow("xyz").SwfObject("abc").GetTextLocation("pqr",l,t,r,b,True)
    
    myX = SwfWindow("xyz").SwfObject("abc").GetROProperty("x")
    myY = SwfWindow("xyz").SwfObject("abc").GetROProperty("y")
    x= (l+r)/2
    y=(t+b)/2
    
    myX = myX + x
    myY = myY + y
    SwfWindow("xyz").Activate
    Set dr = CreateObject("Mercury.DeviceReplay")
    
    dr.MouseClick myX, myY, 0

End Sub