Macro command allows automatically select “OK”

Dear community, I am writing a macro for batch processing images. Everytime when a new file open, a window pops up, titled " Bio-Formats Import Options". I alway choose the default setting and click “OK”. Is there a way that I can make this automatically select “OK”, so that I don’t have to click “OK” for every individual file? It seems like it should be a simple bit of code, but I haven’t found a workaround.


Have you been using the macro recorder? It can be launched via Plugins > Macro > Record… and I find it really helps in situations like this as it records what you do in FIJI as it would be written in a macro.

If you open a file that needs to be imported using Bio-Formats (you might have to go to Plugins > Bio-Formats > Bio-Formats Importer to make it record) you get.

So that means a line like that is needed in your macro. I’ve put a few lines below to show how I tend to do it.

dir1 = getDirectory("Choose Source Directory");
list = getFileList(dir1);
path = dir1 + list[0];
run("Bio-Formats Importer", "open=[" + path  + "] color_mode=Composite rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT");

Hope that helps!