Login  Register

Re: Block useraction during macro execution?

Posted by Michael Schmid on Feb 07, 2017; 4:39pm
URL: http://imagej.273.s1.nabble.com/Block-useraction-during-macro-execution-tp5018034p5018045.html

Hi Norbert,

as far as I can determine, macros running in BatchMode have their own
foreground image, independent of what the user selects. Try the
following macro:

   newImage("imageOne", "8-bit white", 256, 256, 1);
   newImage("imageTwo", "8-bit white", 256, 256, 1);
   setBatchMode(true);
   showStatus("Select image while BatchMode on");
     for (i=0; i<10; i++) {
     wait(1000);
     print("Macro foreground image: " + getTitle() );
   }
   print("Macro done.");

Also imageIDs for selecting images are independent of any other activity
that happens in parallel.

Nevertheless, a BatchMode macro is not immune from influences of
foreground processes, e.g.:
- Modifying/closing an input image (you may duplicate the input image(s)
at the beginning of the BatchMode phase to avoid that)
- Changing global options that affect the macro
- Some built-in commands (such as Process>Math/...) and external plugins
are not written for concurrent operation in multiple threads.  E.g.
filter parameters are often stored in static class variables, and these
variables also used for the filtering.  So, if the same function/plugin
is used interactively and by a macro at the same time, it may not work
as intended or fail with an exception.


Michael
________________________________________________________________


On 2017-02-06 17:04, Norbert Vischer wrote:

> Hi all,
>
> Is there a method to block user interference while a macro is running?
> Macro commands that work on the front window can easily be spoilt with
> an unintended click in the wrong window.
>
> For example a command like this one would make life simpler when
> distributing macros:
>
> blockUserInteraction(boolean)
>   During macro execution, any user action that would
>   activate a different image window is blocked.
>   It still is possible to move a window
>   via command-click in the title bar.
>
> Norbert
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html