Forum Discussion

almmatt's avatar
almmatt
Contributor
10 years ago

Get cursor coordinates over tested object?

Does anyone have a way a to get the cursor coordinates over a tested object during test execution?   I am working an unsupported control and I have a method to place the cursor over a particular re...
  • almmatt's avatar
    almmatt
    10 years ago

    Thanks for the assistance everyone, I was able to get what I needed. Here's the script I wrote to get the current X & Y coordinates and double click the object at that point.

     

    var screenMouseX, screenMouseY, controlPoint, onscreenObj;
    
    function double_click()
    {
    
    //Gets current mouse cursor coordinates on screen
    screenMouseX = Sys.Desktop.MouseX;
    screenMouseY = Sys.Desktop.MouseY;
    
    Log.Message("X: " + screenMouseX + " Y: " + screenMouseY);
    
    //gets the object below the mouse cursor
    onscreenObj = Sys.ObjectFromPoint(screenMouseX,screenMouseY); 
    
    //converts the screen coordinates to coordinates relative to the object
    controlPoint = onscreenObj.ScreenToWindow(screenMouseX,screenMouseY);
    
    Log.Message("objX: " + controlPoint.X + " objY: " + controlPoint.Y);
    
    //double clicks the object from the converted coordinates
    onscreenObj.DblClick(controlPoint.X,controlPoint.Y);
    
    }