• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Auto text flow script

Contributor ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

Does anyone have a script that turns off the smart text flow preference? I'd like to apply the script when the document is opened.

 

Thanks

 

 

 

TOPICS
How to , Scripting , Type

Views

837

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Mar 15, 2023 Mar 15, 2023

Hi @Davis_XI, you must specify a target engine for these event listeners to work. In VSCode a target engine directive should begin with "//@targetengine". Try this exact code:

//@targetengine "smartText";

app.addEventListener("afterOpen", changeSmartText);
// alert('New "afterOpen" event listener is active.');

function changeSmartText(e) {
    if (e.parent.constructor.name == "LayoutWindow") {
        e.parent.parent.textPreferences.smartTextReflow = false;
        alert('Smart Text Reflow = '
...

Votes

Translate

Translate
Community Expert , Mar 15, 2023 Mar 15, 2023

It's still not working after i moved it to the startup scripts folder.

 

Did you restart InDesign? Try adding an alert to test the listener, and include the targetengine line. Change to this and restart after you add it to the startup folder:

 

#targetengine "smartText";

app.addEventListener("afterOpen", changeSmartText);

function changeSmartText(e) {
    if (e.parent.constructor.name == "LayoutWindow") {
        e.parent.parent.textPreferences.smartTextReflow = false;
        alert("This docu
...

Votes

Translate

Translate
Community Expert ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

Hi @Davis_XI, this little script should turn it off. - Mark

var doc = app.activeDocument;
doc.textPreferences.smartTextReflow = false;
alert('Smart Text Reflow = ' + doc.textPreferences.smartTextReflow);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

Hi @Davis_XI , do you want it to happen automatically every time any document is opened? In that case it would have to be a startup script that listens for an open event.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

Hi Rob, in a perfect world that is how it would work. I've been looking into how to create an open event.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

You could run this from your scripts panel, and any document you open while ID is running would have the preference set.  Or you can put it in your startup scripts folder and it will always run on a startup:

 

 

#targetengine "smartText";

app.addEventListener("afterOpen", changeSmartText);
function changeSmartText(e) {
    if (e.parent.constructor.name == "LayoutWindow") {
        e.parent.parent.textPreferences.smartTextReflow = false;
    }
};

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

Hi Rob, thanks but I can't seem to get it to work. So far I've only tried running it with a document open. Is it referencing the previous script or will it work by itself? Really sorry for asking stupid questions ☺️ 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

It’s listening for an open event, so it wouldn’t affect a document that is already open.

 

Does it work if you close then reopen the document?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

Thanks for being patient.

It's still not working after i moved it to the startup scripts folder. I'm saving it down from Visual Studio Code. Could it be something wrong there. Here is the code copied out of VSC - 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

Hi @Davis_XI, you must specify a target engine for these event listeners to work. In VSCode a target engine directive should begin with "//@targetengine". Try this exact code:

//@targetengine "smartText";

app.addEventListener("afterOpen", changeSmartText);
// alert('New "afterOpen" event listener is active.');

function changeSmartText(e) {
    if (e.parent.constructor.name == "LayoutWindow") {
        e.parent.parent.textPreferences.smartTextReflow = false;
        alert('Smart Text Reflow = ' + e.parent.parent.textPreferences.smartTextReflow);
    }
};

 - Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

It's still not working after i moved it to the startup scripts folder.

 

Did you restart InDesign? Try adding an alert to test the listener, and include the targetengine line. Change to this and restart after you add it to the startup folder:

 

#targetengine "smartText";

app.addEventListener("afterOpen", changeSmartText);

function changeSmartText(e) {
    if (e.parent.constructor.name == "LayoutWindow") {
        e.parent.parent.textPreferences.smartTextReflow = false;
        alert("This document's Smart Text Reflow has been set to: " + e.parent.parent.textPreferences.smartTextReflow)
    }
};

 

I get this everytime I open a document:

 

Screen Shot 3.png

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 16, 2023 Mar 16, 2023

Copy link to clipboard

Copied

Perfect. Once again, thank you for your patience.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 14, 2023 Aug 14, 2023

Copy link to clipboard

Copied

LATEST

RAJKUMAR

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines