Does anyone know how to do do this in a macro:
1) check if the active window is an image window or a text window or a table window 2) get the name (title) of the active text window or table window Everything I have tried just ignores text windows and reports the above info from the active image window. It is ok for me to use a java snippet as long as it is callable inside a normal macro. I can provide examples if this question is unclear. Stein -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Stein,
here is a small Jython Macro that will print details about all open windows. from ij import WindowManager as wm list = wm.getNonImageWindows() print list Have a look at [1] to see all methods that are provided by the class ij.WindowManager. I don't know how to do this with basic IJ macro code, but I think the eval function is the clue. Best regards Michael Entrup [1]: http://rsbweb.nih.gov/ij/developer/api/ij/WindowManager.html Am 01.07.2014 15:31, schrieb Stein Rørvik: > Does anyone know how to do do this in a macro: > > 1) check if the active window is an image window or a text window or a table window > > 2) get the name (title) of the active text window or table window > Everything I have tried just ignores text windows and reports the above info from the active image window. > It is ok for me to use a java snippet as long as it is callable inside a normal macro. > I can provide examples if this question is unclear. > > Stein > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Stein Rørvik
Hi Stein,
currently, the ImageJ macro language has a command getInfo("window.type") which returns ("Image", "Text", "ResultsTable", "Editor", "Plot", "Histogram", etc. http://rsb.info.nih.gov/ij/developer/macro/functions.html#getInfo-label As far as I know, there is no function like getInfo("window.name") which gives you the name of the current Text Window; we only have getTitle() for image windows. If Wayne reads this, maybe he will add such a function? Maybe roughly like this... ... } else if (lowercaseKey.equals("window.name")) { Window win = WindowManager.getActiveWindow(); if (win==null) return ""; else if (win instanceof Frame) return ((Frame)win).getTitle(); else if (win instanceof Dialog) return ((Dialog)win).getTitle(); else return ""; //JWindow or something else? } <the last case is not accounted for in ImageProcessor.getNonImageTitles(); maybe one can omit it> Michael ________________________________________________________________ On Jul 1, 2014, at 15:31, Stein Rørvik wrote: > Does anyone know how to do do this in a macro: > > 1) check if the active window is an image window or a text window or a table window > > 2) get the name (title) of the active text window or table window > Everything I have tried just ignores text windows and reports the above info from the active image window. > It is ok for me to use a java snippet as long as it is callable inside a normal macro. > I can provide examples if this question is unclear. > > Stein -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
On Jul 1, 2014, at 12:51 PM, Michael Schmid wrote:
> Hi Stein, > > currently, the ImageJ macro language has a command > getInfo("window.type") > which returns ("Image", "Text", "ResultsTable", "Editor", "Plot", "Histogram", etc. > http://rsb.info.nih.gov/ij/developer/macro/functions.html#getInfo-label > > As far as I know, there is no function like > getInfo("window.name") > which gives you the name of the current Text Window; we only have getTitle() for image windows. > > If Wayne reads this, maybe he will add such a function? The latest ImageJ daily build (1.49d6) adds a getInfo("window.name") macro function. getInfo("window.title") will also work. -wayne > Maybe roughly like this... > > ... > } else if (lowercaseKey.equals("window.name")) { > Window win = WindowManager.getActiveWindow(); > if (win==null) return ""; > else if (win instanceof Frame) return ((Frame)win).getTitle(); > else if (win instanceof Dialog) return ((Dialog)win).getTitle(); > else return ""; //JWindow or something else? > } > > <the last case is not accounted for in ImageProcessor.getNonImageTitles(); maybe one can omit it> > > > Michael > ________________________________________________________________ > On Jul 1, 2014, at 15:31, Stein Rørvik wrote: > >> Does anyone know how to do do this in a macro: >> >> 1) check if the active window is an image window or a text window or a table window >> >> 2) get the name (title) of the active text window or table window >> Everything I have tried just ignores text windows and reports the above info from the active image window. >> It is ok for me to use a java snippet as long as it is callable inside a normal macro. >> I can provide examples if this question is unclear. >> >> Stein > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |