Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Due to circumstances that did not allow us to allocate much cost to this project, this was a compromise.
#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.
Copy link to clipboard
Copied
@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.
Copy link to clipboard
Copied
Next time - could you please describe your problem in more detail - what EXACTLY are you trying to achieve?
Copy link to clipboard
Copied
Please refer to my post below.
and
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.
Copy link to clipboard
Copied
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 )
Copy link to clipboard
Copied
> 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.
Copy link to clipboard
Copied
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:
Regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
@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.
Copy link to clipboard
Copied
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
Issues
Copy link to clipboard
Copied
The Find/Change window could be open but buried behind other UI panels. Wouldn’t that also be a problem?
Copy link to clipboard
Copied
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.