Finally got my code working except for one if statement that I cannot fix. I am selecting ROIs 3 and 4 in the first step, and then if the "if" statement is satisfied I want to select just the 4th ROI and delete that. For whatever reason it skips the selection of ROI 4 and deletes the already selected 3 and 4. I've tried selectWindow("ROI Manager"); before with no luck. Not really sure what the issue is or how to fix. Thanks!
roiManager("Select", newArray(3,4));
roiManager("Measure");
tempX1=getResult("X", 0);
tempY1=getResult("Y", 0);
tempX2=getResult("X", 1);
tempY2=getResult("Y", 1);
selectWindow("Results");
run("Close");
if (tempX1>(tempX2-2) && tempX1<(tempX2+2) && tempY1>(tempY2-2) && tempY1<(tempY2+2)) {
selectWindow("ROI Manager");
roiManager("Select", 4);
roiManager("Delete");
}