How to determine the continuous execution of code? I only want a piece of code to run once.
I have chosen some text.
First run: I want to restore the line spacing of the selected text to the "original paragraph style" line spacing of the first paragraph.
Second run: Take the line spacing of the first paragraph of text, add a dot, and then apply it to the selected text.
After the third time, repeat the second operation.
It's a bit contradictory, these are two separate actions. We need to ensure that the line spacing is restored to its original state while also increasing it on top of it.
var d = app.activeDocument;
var item = app.selection[0];
//-----------------------A-------------------
//Apply the first leading to the selected text
var OriginalStyleLeading = item.paragraph[0].appliedParagraphStyle.leading;
app.selection[0].text[0].leading = OriginalStyleLeading;
//-----------------------B-------------------
//Adjust line spacing When operating continuously, only repeat this step
var firstParLeading = item.paragraph[0].appliedParagraphStyle.leading;
app.selection[0].text[0].leading = firstParLeading + 1;After the second time, only part B can be repeated.
Is it possible use a clock to determine whether to execute for the first time? For example, within 3 seconds, it is considered as the second time.
