Closed Sethur closed 1 year ago
@rasband Can you reproduce this?
I am looking into this problem. Note that the File.getDefaultDir macro function returns the default OpenDialog directory. Use getDir("cwd") to get the current working directory.
I was able to reproduce this bug on MacOS and fix it in the ImageJ 1.54c7 daily build.
@rasband Thank a lot for your continued effort invested in this project!
Configuration: Java 1.8.0_311 (x64) ImageJ 1.53k Windows 10.0.19042.1466
Steps for Reproduction
Run ImageJ, go to
Edit->Options->Misc
, and checkSingle instance listener
Create
openFile.ijm
macro file inside %IMAGEJ_HOME%\macrosIJ.log("Current working directory in macro: " + File.getDefaultDir); IJ.log("Macro file path argument sent to plugin: " + filePath);
run("Example Plugin", "select=&filePath");
setBatchMode("exit and display")
import ij.IJ; import ij.plugin.PlugIn; import ij.io.OpenDialog;
public class Example_Plugin implements PlugIn {
}
f:\MainDir> %IMAGEJ_HOME%\ImageJ-win64.exe -macro OpenFile.ijm Foo.tif f:\MainDir> cd SubDir f:\MainDir\SubDir> %IMAGEJ_HOME%\ImageJ-win64.exe -macro OpenFile.ijm Bar.tif
Current working directory in macro: f:\MainDir\ Macro file path argument sent to plugin: Foo.tif Current working directory in plugin: f:\MainDir File argument from plugin: Foo.tif Current working directory in macro: f:\MainDir\SubDir\ Macro file path argument sent to plugin: Bar.tif Current working directory in plugin: f:\MainDir File argument from plugin: Bar.tif