Creating an interactive macro in simple words

Hei there!

This question is probably floating around in the forum already, but since I do not know with which exact phrases I can find it i apologize in advance for the question.

I am trying to create a makro that lets me select two things in between before proceeding with the further actions.
In detail: I want the “line-tool” to be chosen, set the line myself, run the “set scale” and set the line to 1 cm. Then I want the brightness/contrast window to open, set the brightness myself and the polygon tool to be selected, choose the exact polygon position myself, measure the area and close the picture without saving changes.
When I record a macro, it looks like this:

makeLine(840, 764, 948, 430); #instead of those numbers I need to set the line myself differently for every picture. how do I do that?
run("Set Scale...", "known=1 unit=cm");
makePolygon(1254,524,1300,542,1350,550,1404,552,1456,548,1510,572,1550,608,1600,644,1568,696,1550,728,1468,712,1404,724,1358,718,1314,704,1228,696,1204,682,1142,670,1120,634,1112,586,1140,558,1178,532,1224,522); #same as above, instead of those coordinates that set the area for every picture the same, I need to set this area myself

I am a complete programming illiterate and sadly don’t understand most of the tutorials and helps and comments, so I would appreciate simple words :slight_smile:
(I’m using Fiji)

Thanks in advance!

Welcome to the forum, @Luckilia!

Have a look at the list of macro function, particularly waitForUser(string) and the example macro provided there. As you saw by recording your own macro, a macro is simply a series of commands executed one by one. If you want to include an interactive step and pause the macro to get e.g. a line selection, you can use:

waitForUser("Please make a line selection and click OK");

and the macro will only continue after clicking OK in the displayed dialog.

Hope that helps,

1 Like