Fiji macro does not wait a command finished before running the next command




I use Fiji 1.51p. I am writing a macro. In it, I run a plugin : run(“IHC ToolBox”), written in Java. Other commands are following this run statement. When I execute the macro, Fiji does not wait for the end of plugin execution before to the next command. Of course the macro is unusable by this way.

What to do to force Fiji to wait the plugin execution end ?

Thank you.



I have never had to run such a thing in a macro… however, there are a ton of people on the Forum who have - of course!

Just to get you started in testing a few things… there should be a few Built-In Macro Functions (a great place to search for applicable functions) that could help, such as:

Delays (sleeps) for n milliseconds.

Halts the macro and displays string in a dialog box. The macro proceeds when the user clicks “OK”. Unlike showMessage, the dialog box is not modal, so the user can, for example, create a selection or adjust the threshold while the dialog is open. To display a multi-line message, add newline characters ("\n") to string. This function is based on Michael Schmid’s Wait_For_User plugin. Example: WaitForUserDemo.

waitForUser(title, message)
This is a two argument version of waitForUser, where title is the dialog box title and message is the text displayed in the dialog.

This is a no argument version of waitForUser that displays “Click OK to continue” in the dialog box.

I hope this is at least a start for you for testing…

eta :slight_smile:


Hi Tryphon,

Just to add to the detailed advice from @etarena which concerns macros; you could use one of the available scripting languages to avoid this issue altogether. If I’m not mistaken.




Thank you for your detailed reply.

wait(n) : I do not know how to manage the time because the plugin may run 1 s or several minutes depending of the work complexity.

waitForUser : in fact the macro is run in batch processing for a lot of images (thousand). I do not want to click!

This how I work around the problem :
while (File.exists(dummyFile.txt)==0) {
// Nothing needed here. Just wait for plugin to end.

where dummyFile.txt is generated by the modified plugin executed in my macro.


Unluckily, I work in an institution which block website (I cannot reach the wiki example).

Thank you, the issue is solved.


Any update on the wiki example please? Thank you