Re: Close all but active window
Posted by
Michael Schmid on
Nov 14, 2016; 5:51pm
URL: http://imagej.273.s1.nabble.com/Close-all-but-active-window-tp5014024p5017581.html
Hi Haleh,
sorry, you can have only one window selected at a time.
If you need to keep more than one image, you have to create a loop over
all images.
Here is a rough Javascript example. It only cares about visible images,
not about images created in BatchMode or images not shown for other reasons.
allIDs = WindowManager.getIDList();
if (allIDs==null) exit(); // return;
for (i = 0; i<allIDs.length; i++) {
imp = WindowManager.getImage(allIDs[i]);
title = imp.getTitle();
if (title != "Stack1.tif" && title != "Stack1.tif") {
win = imp.getWindow();
if (win != null) {
imp.changes = false;
win.close();
}
}
}
Michael
________________________________________________________________
On 2016-11-14 17:51, Haleh wrote:
> Hi Michael,
>
> Sorry for responding late. I just checked Javascript with your
> command, it works quite well :). Thanks a lot. This saves me a lot of
> time. Thanks again for your explanation of backslashes. It was worth
> to learn it. One question, are we able to choose two window (two
> Images) by using selectwindow (). I would like to keep two or three..
> window open (Among several images) in order to do process on them and
> close others. like:
>
> IJ.selectWindow("Stack1.tif"); IJ.selectWindow("Stack2.tif");
> IJ.runMacro("print(\"work\");close(\"\\\\Others\");print(\"done\");");
>
>
> As you know selectWindow() just considers last window then close all.
> Is there any way to select more than one window ?
>
> Thank you in advance, Haleh
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html