Re: Get windows titles
Posted by Ben.BigHair on
URL: http://imagej.273.s1.nabble.com/Get-windows-titles-tp3700495p3700496.html
Christophe Leterrier wrote:
> Hi,
>
> 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 ?
>
Hello,
Perhaps something like the following would work for you?
Ben
//BEGIN
id = getImageList(false);
name = getImageList(true);
for (i=0;i<nImages();i++){
write('ID = ' + id[i] + ', NAME = ' + name[i]);
}
function getImageList( bReturnNames ){
count = nImages();
if (count == 0) then return -1;
setBatchMode(true);
currentID = getImageID();
id = newArray(count);
if (bReturnNames == true) {
names = newArray(count);
}
for (i=0;i<count;i++){
selectImage(i+1);
id[i] = getImageID();
if (bReturnNames == true) {
names[i] = getTitle();
}
}
selectImage(currentID);
setBatchMode(false);
if (bReturnNames == true) {
return names;
} else {
return id;
}
}
//END