Forum Discussion

ezzmonem's avatar
New Contributor
5 years ago

Regions.Compare with Masks

I am using Regions.Compare method in an If condition for branching between two different scenarios based on the displayed window. I don't use Check because it takes a longer time to process and generates a log error that terminates the script. Is there any way to include masks while using Compare? or is there any other way to compare a region as a branching condition (not as a region checkpoint) and still be able to use masks?

3 Replies

  • ezzmonem's avatar
    New Contributor



    Thank you for your help!

    PictureObject.Compare worked fine with masks.

    I implemented it this way:

    var appRegion = Regions.CreateRegionInfo(
    AObject, 0, 0, width, height, false);

    var baselinePicture= Regions.GetPicture("baseline_1");
    var baselineMask= Regions.GetPicture("baseline_1_Mask");


    if(baselinePicture.Compare(appRegion .Picture(), false, 0, false, 0, baselineMask)){




  • tristaanogre's avatar
    Esteemed Contributor

    Well,first of all, I don't like having "Stop on error" set to true... I like to have more granular control over when my automation stops.  So, if turn that off, then Regions.Check would work for you.


    You could go the route of Picture.Compare (


    It's a bit different than Region compare... you wouldn't have a stored region in the system, you'd be using an external picture file loaded in.  I use this freqently and does pretty well.

  • Hi, ezzmonem 


    Is it an option to use the Picture.Compare method?

    Picture.Compare allows a mask to be used



    In my scripts I use a combination of the and method


    if (!pic_1.Compare(pic_2, ............., maskImg))


    Regions.Compare(pic_1, pic_2)