Here is the script that Pickory mentioned, with a small addition to add a text condition, as he suggested, to the found words rather than listing them.
First add a text condition to your document. Use the name Typo and set its appearance. Then run the script.
(function () {
const props = app.spellPreferences.properties;
const spellWindow = app.menuActions.item ('$ID/Check Spelling...');
var typos = [];
var knownTypo = {};
function record (typo) {
if (!knownTypo[typo]) {
knownTypo[typo] = true;
typos.push (typo);
}
}
// Begin ----------------------------------------------
const condition = app.activeDocument.conditions.item('Typo');
if (!condition.isValid) {
alert ('Create a condition "Typo"');
exit();
}
// Hide the layout window to speed things up
app.windows[0].minimize();
app.spellPreferences.properties = {
checkCapitalizedSentences: false,
checkCapitalizedWords: false,
checkRepeatedWords: false,
checkMisspelledWords: true
}
spellWindow.invoke();
if (!app.selection.length) { // No spelling errors, nothing to do
exit();
}
// If there's a typo, it's now selected
record (app.selection[0].contents);
var i = app.selection[0].index; // The location of the typo
spellWindow.invoke();
while (app.selection[0].index !== i) { // Stop when we catch the same word
i = app.selection[0].index;
record (app.selection[0].contents);
spellWindow.invoke(); // Go to the next typo
}
app.selection = null;
// Restore the layout window and the spell preferences
app.activate();
app.spellPreferences.properties = props;
// Create a new document and add the typos.
//app.documents.add().textFrames.add ({
// geometricBounds: app.documents[0].pages[0].bounds,
// contents: typos.sort().join('\r'),
//});
app.findTextPreferences = app.findChangeTextOptions = null;
app.changeTextPreferences.appliedConditions = [condition];
app.findChangeTextOptions.wholeWord = true;
for (var i = typos.length-1; i >= 0; i--) {
app.findTextPreferences.findWhat = typos[i];
app.activeDocument.changeText();
}
}());
... View more