I am new to ImageJ macros and I want to use a macro in Fiji. The code for the macro is from this source.
macro "MultiRoiMove Tool - C00cT0f16M" {
if (RoiManager.selected<2) exit();
indexes=split(call("ij.plugin.frame.RoiManager.getIndexesAsString"));
roiManager("Combine");
getCursorLoc(x, y, z, modifiers);
Roi.getBounds(x0, y0, width, height);
while(modifiers&16>0) {
getCursorLoc(x1, y1, z, modifiers);
Roi.move(x0+x1-x, y0+y1-y);
}
roiManager("select", indexes);
roiManager("translate", x1-x, y1-y);
}
I have downloaded the code and saved it as a text file. I have then run the macro through going to Plugins > Macros > Run. The version of ImageJ I am using is 1.53j.
However, when I run the macro, I am getting the following error:
I have seen online on the ImageJ forum that this macro works for other people. I have done some debugging and know that I am getting the error because the code does not go into the while loop when I run the macro, so there isn't a value for x1
returned by the getCursorLoc
function.
But I am not how to get the code to go into the while loop. Does anyone know if I have to click something specific before running the macro? It seems to me that the code will go into the while loop when a mouse modifier event occurs (as the modifiers parameter returned by the getCursorLoc function are the mouse event modifier flags). Any help is appreciated.