Forum Discussion

poffin's avatar
poffin
Occasional Contributor
8 years ago
Solved

Regions.Compare images including mouse?

I'm attempting to use the Regions.Compare() method to compare the state of an object before and after I perform an operation. The images are supposed to be identical.

 

My problem is, I cannot get the compare method to disregard the mouse. The documentation says that by default the include mouse option is false, however even if I set it to false myself, it still seems to compare the object with the mouse. I read that it's possibly not the mouse itself, but the shadow on the mouse, so I added a pixel tolerance of 200 px, and the comparison still returns false.

 

Here's the code (in jscript):

 

var wnd = Aliases.Application.MainWindow;
var pic1 = wnd.Studio.ScrollViewer.ScrollViewer.Picture();

wnd.Pulses.Drag(104, 220, 385, 13);

var pic2 = wnd.Studio.ScrollViewer.ScrollViewer.Picture();

Regions.Compare(pic1, pic2, false, false, true, 200);

And attached are the two pictures that are being compared. What am I doing wrong? There's no way that the mouse shadow is greater than 200 px, so something else must be different as well.

  • I believe you meant to use picture compare method and not the region compare.

     

     

    Edit:

    Also you need to specify the mouse pointer exclusion when you use the .Picture() method.

    See documentation here.

     

     

    Try this (again, lol):

     

    var wnd = Aliases.Application.MainWindow;
    var obj = wnd.Studio.ScrollViewer.ScrollViewer
    
    //take first picture specifying mouse is not to be captured
    var pic1 = obj.Picture(0, 0, -1, -1, false);
    
    //perform object drag
    wnd.Pulses.Drag(104, 220, 385, 13);
    
    //take second picture specifying mouse is not to be captured
    var pic2 = obj.Picture(0, 0, -1, -1, false);
    pic1.Compare(pic2);

     

3 Replies

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor

    I believe you meant to use picture compare method and not the region compare.

     

     

    Edit:

    Also you need to specify the mouse pointer exclusion when you use the .Picture() method.

    See documentation here.

     

     

    Try this (again, lol):

     

    var wnd = Aliases.Application.MainWindow;
    var obj = wnd.Studio.ScrollViewer.ScrollViewer
    
    //take first picture specifying mouse is not to be captured
    var pic1 = obj.Picture(0, 0, -1, -1, false);
    
    //perform object drag
    wnd.Pulses.Drag(104, 220, 385, 13);
    
    //take second picture specifying mouse is not to be captured
    var pic2 = obj.Picture(0, 0, -1, -1, false);
    pic1.Compare(pic2);

     

    • poffin's avatar
      poffin
      Occasional Contributor

      Changing the .Picture() method did the trick! Thank you for your help.