Copy link to clipboard
Copied
Hi,
here in this forum I found Russ's find/change function in ExtendScript with which you can find and replace texts. The script works perfectly when the documents are open. In the case of invisibly open documents the script does not work since TextSelection is obviously applied. Refer to link:
https://forums.adobe.com/message/4032650#4032650
As I want to search and replace texts within a book structure it would be useful if I could do this in documents which are not visibly open (Constants.FS_MakeVisible = false). Does anybody have an approach to search and replace in documents which are not visibly open? Or can anybody confirm that this is solely possible with TextSelection which means that it does not work in invisibly open documents?
Thank you very much!
Regards
Apollo102
Apollo,
I looked into this and I was able to replicate the problem. Unfortunately, I was not able to find a perfect solution. Running through the debugger, I found that the failure occurs with the Find() call. All paragraphs, text ranges, etc. are valid... it's just that the Find() call fails to find anything.
I did find that if you toggle the display, suddenly the Find() operation works with the document hidden:
doc.IsOnScreen = true;
doc.IsOnScreen = false;
I don't know if that is a practical solut
...Copy link to clipboard
Copied
Apollo,
I looked into this and I was able to replicate the problem. Unfortunately, I was not able to find a perfect solution. Running through the debugger, I found that the failure occurs with the Find() call. All paragraphs, text ranges, etc. are valid... it's just that the Find() call fails to find anything.
I did find that if you toggle the display, suddenly the Find() operation works with the document hidden:
doc.IsOnScreen = true;
doc.IsOnScreen = false;
I don't know if that is a practical solution and of course, you might as well just open it visible in the first place. Would be of any help to just disable updates with the entire interface?
app.Displaying = false;
Just be sure to reset that to true at the end of the script
I'm sorry that I couldn't find a complete solution. It might be possible to call something that makes the hidden document searchable, but I didn't figure it out.
Russ
Copy link to clipboard
Copied
Dear Russ
Thanks for your reply.
"app.Displaying = false" seems to have an effect. However, it stills seems that the screen display is refreshed several times (particularly when the program is running in a network). However, documents are not displayed any longer.
Maybe I need to place the command at another position. However I am a little bit surprised that such a use is intended. I thought that only statuses can be read (according to Scripting Guide). The same applies to IsOnScreen.
I need to carry out some thorough tests regarding IsOnScreen. I think that the use would not be totally safe because the cause of the effect is still unclear.
Thanks for your support. It is, as always, a great help to me.
Regards
Apollo
Copy link to clipboard
Copied
Be careful with app.Displaying = false (or app.Displaying = 0). According to correspondence I had with Adobe, this command is now "stack based" and there can be side-effects if you set the property to the same value more than once. I can confirm this in my tests. Here is how I use it to prevent this:
if (app.Displaying === 1) {
app.Displaying = 0;
}
And of course at the end of the script you have to restore it.
if (app.Displaying === 0) {
app.Displaying = 1;
}
This is an FDK issue, because I have seen it in plugins, ExtendScript scripts, and FrameScript scripts. -Rick
Copy link to clipboard
Copied
Thanks Rick, I can confirm that behavior and should have mentioned it originally. To set app.Displaying=1 when it already equals 1 will send FM to a very bad place.
Russ
Copy link to clipboard
Copied
Hi Rick,
thank you. Good point. Thanks for your support.
Regards
Apollo102