Saving 'Recorder' plugin output from macro

I am writing an interactive macro (it stops every now and then to wait for user) where I am recording some preprocessing steps to keep track of the threshold the user manually selects, etc. I would like to have a way to automatically save to file whatever the recorder plugin prints, at the end of the macro. In practice, I would like to avoid having to manually export the recorder output window to the editor and then manually save from the editor. Is it there a way to do these steps calling them from a line in my macro instead?

Dear @lauras,
I’m assuming your printing out text with to the Log window. The saveAs() function can be used to save a log window as a text file. You will need to specify an output folder at the start of the macro.
Here is an example macro which will ask for an output folder, print the phrase “Hello World”, and then save the Log window to a text file in the output folder.

outputfilepath=getDirectory("Choose a Output folder");

//Your Macro Functions
print("Hello World");

saveAs("Text", outputfilepath+File.separator+"Log.txt");

Let me know if this helps.

@Spencer Lab. Thanks for your answer. Unfortunately this is not what I am trying to do. I would like to save the output of the Recorder window generated by the Record plugin, so that one can keep track of everything done by the user when processing the images. I would like something like:

saveAs(“Text”, “Recorder.txt”);

The Recorder output, however, does not seem to be a text window and I am not sure how I can access it. I suppose it is some sort of java class with possibly (?) some associated methods that should allow one to interact with it, but I do not understand how to do it from the source code of the Recorder plugin (I have no experience with Java)

1 Like

Interesting, I am not sure how to do this either. @etadobson any thoughts on how to either save the text out of the macro recorder window in a macro, or activate the Create button automatically (which would then let @lauras save that as a text file).

Would it be possible to change the function createMacro() in the to public?

Then to above inquiry can be solved with the following plugin which can be called via macro:

import ij.plugin.PlugIn;
import ij.plugin.frame.Recorder;

public class Recorder_Create implements PlugIn{
	public void run(String arg) {
		if (Recorder.record){
1 Like

I’m not sure… perhaps a workaround… so using

getString(“prompt”, “default”)
Displays a dialog box and returns the string entered by the user. The first argument is the prompting message and the second is the initial string value. Exits the macro if the user clicks on “Cancel” or enters an empty string. See also: Dialog.create.

Then you can have the user copy/paste the code snippet into the dialog box and save/print that String to the Log window. That’s all I can come up with at the moment…

1 Like