Posted by
Krs5 on
Nov 15, 2016; 8:54am
URL: http://imagej.273.s1.nabble.com/Close-all-but-active-window-tp5014024p5017582.html
Dear Haley,
Maybe you can create one stack from Stack1.tif and Stack2.tif, close all other images and split the stack back into the 2 individual stacks.
Kees
-----Original Message-----
From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of Michael Schmid
Sent: 14 November 2016 17:51
To:
[hidden email]
Subject: Re: Close all but active window
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--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html