User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

faq:macros:how_do_i_make_a_macro_run_automatically_when_imagej_starts [2019/04/12 13:13] (current)
Line 1: Line 1:
 +====== FAQ: How do I make a macro run automatically when ImageJ starts? ======
 +**I want to run a macro automatically each time that ImageJ starts. How do I do it?**
 +Include your macro code in the **AutoRun** macro, which is in the **StartupMacros.txt** file (this file is located in the ///​ImageJ/​macros///​ folder).
 +**Note:** if you distribute your macros and used the method above to set default options, then other users have to know your Autorun settings, otherwise, their defaults will be different and the macro may not run as intended. ​
 +One possible solution is to paste the AutoRun set of commands at the start of your macro. The disadvantage is that this may override the current settings of the other users without them knowing.
 +Two macro commands
 +  saveSettings();​
 +and \\
 +  restoreSettings();​
 +may be useful to save the current state of IJ:
 +  - add **saveSettings();​ **as the first command of the macro to save the (other) user settings,
 +  - then add your **AutoRun** commands (so the defaults in the user machine are the same as in yours),
 +  - then add **your macro commands**, and
 +  - finally restore the user original settings with **restoreSettings();​** at the end of the macro.
faq/macros/how_do_i_make_a_macro_run_automatically_when_imagej_starts.txt ยท Last modified: 2019/04/12 13:13 (external edit)