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

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

Community Expert ,
Mar 26, 2024 Mar 26, 2024

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.

TOPICS
Scripting

Views

1.1K

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 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

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

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 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

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.

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 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

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 )

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 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

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.

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 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

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.

 

 

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 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

Hi @leo.r This is another interesting idea. Thanks.
However, I don't expect it to work well if the active tab is anything other than either Text or Grep.

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 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

Thats a good idea @Laubender but we can open the dialog using shortcuts ctrl+f and then close it using the escape key will this be trapped by the menu event handler? I doubt

-Manan

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 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

Oh, maybe...
"command + F", "esc" to confirm the hidden status at any time?

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 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

quote

Oh, maybe...
"command + F", "esc" to confirm the hidden status at any time?


By @ajabon grinsmith

 

That's a good idea. But since you want it visible you probably need the esc > Cmd-F sequence which will guarantee the window is open.

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 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

This is still in the testing phase so I am only processing macOS only.

 

var escKey = 'tell application \"System Events\"\r key code 53\r	end tell'
var cmdF = 'tell application \"System Events\"\r	key code 3 using command down\r	end tell';

var doc = app.activeDocument;
var sel = doc.selection;
doc.stories[-1].insertionPoints[-1].select();

doAS(escKey);
doAS(cmdF);
doAS(escKey);
doAS(cmdF);

doc.selection = sel;

function doAS(str){
    app.doScript (str, ScriptLanguage.APPLESCRIPT_LANGUAGE);
}

 

I believe this logic is adequate, but perhaps there is a synchronization issue resulting in occasional errors. Setting a delay somewhere might help stabilize it.

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

Copy link to clipboard

Copied

Hey hi, you can find by trying command.

var findChangeWindow = app.findChangeGrepOptions;
var isWindowVisible = findChangeWindow.properties.panelOptions.visible;

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

Copy link to clipboard

Copied

Is this written by ChatGPT or others?

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

Copy link to clipboard

Copied

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?

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

Copy link to clipboard

Copied

Hi @rob day 

Some of my scripting refer to the set value InDesign's Find/Change GREP setting.
I consider this very reasonable, although there is a risk that the display will be filled with windows momentarily.
And as one user said." If the Find/Change window is not open, I accidentally forget to set it."
I thought to myself, "This is stupid, but there is a big difference between not responding to user requests and not responding to user requests, so I am planning to see if I can open the Find/Change window at the same time the ScriptUI appears.

In fact, it won't make much sense unless the GREP tab is active in addition, but this is the first step in that direction.
Best regards.

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

Copy link to clipboard

Copied

so I am planning to see if I can open the Find/Change window at the same time the ScriptUI appears.

 

Couldn’t you add your own find and change fields to your ScriptUI dialog?

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

Copy link to clipboard

Copied

Here’s a simple example:

 

var f, c;
makeDialog();
function makeDialog(){
    var theDialog = app.dialogs.add({name:"Find and Change", canCancel:true});
    with(theDialog.dialogColumns.add()){
        staticTexts.add({staticLabel:"Find:"});
        staticTexts.add({staticLabel:"Change:"});
    }
    with(theDialog.dialogColumns.add()){
        f = textEditboxes.add({minWidth:200});
        c = textEditboxes.add({minWidth:200});
    }

    if(theDialog.show()){
        app.findGrepPreferences.findWhat = f.editContents;
        app.changeGrepPreferences.changeTo = c.editContents;
        theDialog.destroy();
	}
}

 

 

The script dialog with ID’s Find and Change closed:

Screen Shot 20.png

 

Then, after clicking OK if I open Find /Change I can see the script populated the Find What: and Change To: GREP fields:

 

Screen Shot 21.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
Community Expert ,
Mar 28, 2024 Mar 28, 2024

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.

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

Copy link to clipboard

Copied

I just want to get the values

 

Not sure I’m completely following— if you manage to ensure F&C is open and set to the GREP tab, how will you get the values when the user changes them? Via some kind of listener? You can get the current findGrepPreference properties whether the window is open or closed, but how will you know when they have been changed?

 

This gets the Paragraph Style value whether F&C is open or closed:

 

 

alert("Find Paragraph Style is set to: " + app.findGrepPreferences.appliedParagraphStyle)

 

 

Screen Shot 29.png

Screen Shot 30.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
Community Expert ,
Mar 31, 2024 Mar 31, 2024

Copy link to clipboard

Copied

Values can be retrieved at any time. But it is each user who sets the values.
This requirement was based on a consultation with one user who said, "I sometimes run scripts while forgetting to set various settings in the Find/Change window."
The user believed that the user forgot the settings because the Find/Change window was not open.

Maybe I need to rethink my solution anyway.

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 ,
Apr 01, 2024 Apr 01, 2024

Copy link to clipboard

Copied

quote

Values can be retrieved at any time. But it is each user who sets the values.
This requirement was based on a consultation with one user who said, "I sometimes run scripts while forgetting to set various settings in the Find/Change window."
The user believed that the user forgot the settings because the Find/Change window was not open.

Maybe I need to rethink my solution anyway.


By @ajabon grinsmith

 

In that case there is an extremely simple solution - warning at the beginning of your script(s) - "Have you set Find/Change settings?" and two buttons - "Yes" & "No" - problem solved and no excuses from user...

 

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 ,
Apr 01, 2024 Apr 01, 2024

Copy link to clipboard

Copied

Yes, I understand. I was going to make that a "last resort".
No technological advances there.

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 ,
Apr 01, 2024 Apr 01, 2024

Copy link to clipboard

Copied

quote

Yes, I understand. I was going to make that a "last resort".
No technological advances there.


By @ajabon grinsmith

 

But it should've been your "first resort". 

 

User can always say that the dialog is in wrong place or something. 

 

With this message - there are no excuses and it's a best reminder. 

 

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 ,
Apr 01, 2024 Apr 01, 2024

Copy link to clipboard

Copied

This argument produces nothing. It is futile.
I wrote "I understand". No further mention is needed.


What I want to pursue in this thread is what I stated in the title. That hope is very small.
It is by no means a matter of if this cannot be achieved.
However, I have had some experience with tricky solutions to processes that were hopeless on the DOM.
Isn't that kind of exploration fun?

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

Copy link to clipboard

Copied

quote
[...]

Isn't that kind of exploration fun?


By @ajabon grinsmith

 

Yes, but in this case - not possible.

 

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