Skip to main content
ajabon grinsmith
Community Expert
Community Expert
March 27, 2024
Question

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

  • March 27, 2024
  • 5 replies
  • 2760 views

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.

This topic has been closed for replies.

5 replies

Community Expert
April 3, 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/14517953#M567918

 

Regards,
Uwe Laubender
( Adobe Community Expert )

ajabon grinsmith
Community Expert
Community Expert
April 3, 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. 

ajabon grinsmith
Community Expert
Community Expert
April 3, 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.
Community Expert
March 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.

sneha30692552dvkj
Inspiring
March 28, 2024

Hey hi, you can find by trying command.

var findChangeWindow = app.findChangeGrepOptions;
var isWindowVisible = findChangeWindow.properties.panelOptions.visible;
ajabon grinsmith
Community Expert
Community Expert
March 28, 2024

Is this written by ChatGPT or others?

rob day
Community Expert
Community Expert
March 28, 2024

Hi @ajabon grinsmith , Is the check for the find and change dialog part of a larger script? What happens when you confirm that the dialog is open?

Community Expert
March 27, 2024

Hi @ajabon grinsmith ,

the only thing I can imagine is to add an event listener to the menu command to count if Find/Change is opened, closed etc.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

ajabon grinsmith
Community Expert
Community Expert
March 28, 2024

Hi @Laubender Thanks, to provide this in a single jsx, the user needs to be aware that the ind/Change is visible or hidden when the script is executed. But I see good possibilities.

leo.r
Community Expert
Community Expert
March 28, 2024

You can also probably do something like this (although this will require to toggle the Find window at least once):

 

-Have a text frame with text tool active

-Invoke the Find/Change menu

-Invoke a keystroke (a single key, for example)

-Check your frame contents: it won't change if you've just opened the Find window (the keystroke will go into the Find what field) and vice versa.

 

 

Community Expert
March 27, 2024

Hi @ajabon grinsmith I don't think we have that capability in Extendscript. I am not sure how one would do that even in C++ SDK. We have a panels object in the DOM but that does not have Find/Change as far as I remember, because this is a dialog maybe

-Manan

-Manan
ajabon grinsmith
Community Expert
Community Expert
March 28, 2024

Hi @Manan Joshi Thanks, I am asking the question knowing that.
I often encounter examples where I think I know something is impossible, but there is some surprising solution.
I should have written this first.