Re: Get windows titles
Posted by Wayne Rasband on
URL: http://imagej.273.s1.nabble.com/Get-windows-titles-tp3700495p3700505.html
> I'd like to know if there is a built-in macro function to get the name
> or the ID of all open images (or stacks). I didn't find anything on
> the built-in macro function webpage, appart from "nImages" to get the
> number of open images.
>
> Is there such a function or could someone suggest a simple way to do
> it ?
Use selectImage() and getTitle() in a for loop to get the titles of all
open images.
n = nImages;
list = newArray(n);
for (i=1; i<=n; i++) {
selectImage(i);
list[i-1] = getTitle;
}
To avoid problems with duplicate titles, use getImageID() instead of
getTitle().
n = nImages;
list = newArray(n);
for (i=1; i<=n; i++) {
selectImage(i);
list[i-1] = getImageID;
}
Enable batch mode and the code will run a lot faster because ImageJ
does not have to bring each image to the front.
n = nImages;
list = newArray(n);
setBatchMode(true);
for (i=1; i<=n; i++) {
selectImage(i);
list[i-1] = getImageID;
}
setBatchMode(false);
-wayne