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

How to get whether the Find/Change window is visible or hidden in ExtendScript

Community Expert ,
Mar 26, 2024 Mar 26, 2024

Hi there, 

I want the Find/Change window visible.
I was going to use the menu action to display the Find/Change window, but this toggles it. I would not want to close the window.
Is there a great way to do this?

Regards.

TOPICS
Scripting
2.1K
Translate
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 ,
Apr 02, 2024 Apr 02, 2024

Due to circumstances that did not allow us to allocate much cost to this project, this was a compromise.

スクリーンショット 2024-04-03 15.02.55.png

 

 

#targetengine "session"

// var menuActionName = "検索と置換..."; // Find/Change in Japanese
var menuActionName = "$ID/EditMenu_FindChange"; // thanks to 
var findChangeEventListener = app.menuActions.itemByName(menuActionName).addEventListener("afterInvoke", getAppliedStyles);

var myScriptUI = new Window("""palette{text:"test", 
cStyle:StaticText{characters:32, justify:"left"}, 
pStyle:StaticText{characters:32, justify:"left"}, 
doBtn:Button{text:"do"}
}""");

myScriptUI.onClose = function(){
    findChangeEventListener.remove();
    myScriptUI.eventListeners.everyItem().remove();

}

myScriptUI.addEventListener("focus", function(){
    myScriptUI.doBtn.addEventListener("click", doSomethingFunc);
    myScriptUI.doBtn.visible = true;
    getAppliedStyles();
});

myScriptUI.addEventListener("blur", function(){
    myScriptUI.doBtn.visible = false;
    myScriptUI.doBtn.removeEventListener("click");
    getAppliedStyles();
});

function doSomethingFunc(){
    alert("do something");
}

myScriptUI.show();


function getAppliedStyles(){
    var GrepPref = app.findGrepPreferences;
    myScriptUI.cStyle.text = GrepPref.appliedCharacterStyle;
    myScriptUI.pStyle.text = GrepPref.appliedParagraphStyle;
    }

 

 

(Fixed menu action names and, incidentally, fixed typos due to keyboard malfunction.)

 

I wanted to make it so that the "do" button can only be clicked after the palette is focused, but currently the button can be clicked directly even if the palette is unfocused. It needs one more tweak.
Or confirm.

Translate
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
LEGEND ,
Mar 29, 2024 Mar 29, 2024
quote

@rob day Thanks for the code.
I don't want to manipulate the Find/Change window, I just want to get the values.
Since the values I want to get is not only findWhat, changeTo, but also AppliedParagraphStyle and other options, it is not easy to implement everything I need in ScripUI.
In addition, the implementation of a pulldown to select each style is very demanding, considering the case where the user switches the active document while the ScripUI is displayed.


By @ajabon grinsmith

 

???

 

EVERYTHING that is set-able in the UI - is available though scripting - and you can set those values as well.

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#FindTextPreference.html

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ChangeTextPreference.html

 

And the same with GREP, Object, Glyph, Color.

 

Then there are also *Option - for Text, Grep, Object, Color, Glyph:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#FindChangeTextOption.html

 

EVERYTHING that user can set ANYWHERE in the UI - is accessibe through scripting.

 

Translate
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
LEGEND ,
Mar 29, 2024 Mar 29, 2024

@ajabon grinsmith 

 

Next time - could you please describe your problem in more detail - what EXACTLY are you trying to achieve?

 

Translate
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 31, 2024 Mar 31, 2024

@Robert at ID-Tasker 

Please refer to my post below.

https://community.adobe.com/t5/indesign-discussions/how-to-get-whether-the-find-change-window-is-vis...

and

https://community.adobe.com/t5/indesign-discussions/how-to-get-whether-the-find-change-window-is-vis...

In this thread I would like to have a heated discussion about whether it is possible to get the visibility/Hidden of a Find/Change window. Even if it is somewhat tricky.
I'm not really interested in the argument to begin with.

Translate
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 28, 2024 Mar 28, 2024

Hi @sneha30692552dvkj ,

did you test your ExtendScript code? I get an error message with InDesign 2024, because

app.findChangeGrepOptions has no property that is panelOptions.

 

See DOM documentation:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#FindChangeGrepOption.html

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Translate
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 28, 2024 Mar 28, 2024

Hey hi, you can find by trying command.

 

Hola, that doesn't work because findChangeGrepOptions doesn't have a property panelOptions.

 

Please try out what you suggest, and please don't make up things.

Translate
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 ,
Apr 02, 2024 Apr 02, 2024

Hi @ajabon grinsmith ,

I wonder if the following string for the menu action name is also working with your Japanese InDesign:

var menuActionName = "$ID/EditMenu_FindChange";

Instead of the Japanese one:

var menuActionName = "検索と置換..."; // Find/Change in Japanese

 

Also see my reply in this thread:

https://community.adobe.com/t5/indesign-discussions/open-find-change-panel-by-script-in-indesign/m-p...

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Translate
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 ,
Apr 03, 2024 Apr 03, 2024

@Laubender Oh that's it,

I couldn't remember it at the time. Thank you, thank you.

And thanks for the link to the thread. I should be ashamed that I didn't find this before I posted it - I've been trying to find it for a while now. Even though I'm one of the same Community Expert. (ఠ虫ఠ)
And I read the entire thread... I'll take care of that next time before I post. 

Translate
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 ,
Apr 03, 2024 Apr 03, 2024

Slightly modified.

#targetengine "session"

var menuActionName = "$ID/EditMenu_FindChange";

var myScriptUI = new Window("""palette{text:"test", 
grp:Group{orientation:"column", 
cStyle:StaticText{characters:32, justify:"left"}, 
pStyle:StaticText{characters:32, justify:"left"}, 
doBtn:Button{text:"do"}
}
}""");

myScriptUI.onClose = function(){
    findChangeEventListener.remove();
    myScriptUI.grp.doBtn.eventListeners.everyItem().remove();
    myScriptUI.grp.eventListeners.everyItem().remove();
    myScriptUI.eventListeners.everyItem().remove();
}

var grp = myScriptUI.grp;
var doBtn = grp.doBtn;

doBtn.onClick = doSomethingFunc;

grp.addEventListener("mouseup", function(){
    doBtn.visible = true;
    getAppliedStyles();
});

myScriptUI.addEventListener("blur", function(){
    doBtn.visible = false;
    getAppliedStyles();
});

var findChangeEventListener = app.menuActions.itemByName(menuActionName).addEventListener("afterInvoke", getAppliedStyles);

myScriptUI.show();

function getAppliedStyles(){
    var GrepPref = app.findGrepPreferences;
    grp.cStyle.text = GrepPref.appliedCharacterStyle;
    grp.pStyle.text = GrepPref.appliedParagraphStyle;
    }
    
function doSomethingFunc(){
    alert("do something");
}

 

Requirement

  • When a Find/Change window is opened, closed, or the ScriptUI is focused or unfocused, the StaticText of the ScriptUI reflects the style name.
  • The "do" button cannot be clicked until the ScriptUI is activated once.

 

Issues

  • The "done" button in the Find/Change window does not respond.
  • The "do" button does not appear when the title bar of ScriptUI is clicked.
Translate
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 ,
Apr 03, 2024 Apr 03, 2024

The Find/Change window could be open but buried behind other UI panels. Wouldn’t that also be a problem?

 

Screen Shot 26.png

 

Translate
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 ,
Apr 03, 2024 Apr 03, 2024
LATEST

Oh, yes, there is no end to it.
If the "esc, ⌘+F , esc, ⌘+F" that I'm trying to achieve in the code I posted the other day works reliably, that could be solved too.

Translate
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