Which dialog is causing you problems?
To prevent dialogs you put this in the beginning of your script:
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
But make sure you set it back when you are done:
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
Thats because you still keep yours buttons inactive, I guess
What app.windows.length says?
if there is some, use .close() method
app.windows.length == 0;
It's a window dialog.
var w = new Window ("dialog", "Tool",undefined,undefined);
The odd part is that I'm basically searching a bunch of documents (selected by a window dialog), a bunch of keywords (same way), searching the documents contents (stored as an object) and then displaying the results through a window dialog as a listbox. When I try to store the results to a document it works fine. However when I try to run the script again (calling main()) I get the error.
Are my scripts too app like? I feel like I'm being told I can only ride once per visit and if I want more I'm just going to have to run the script again.
Probably, it goes with error cause app.modalState is true.
You can check this property before run, but how to avoid this?
It was some discussion on forum about that, i.e. here
It could be a huge piece of cake...
I checked modalState before and after the execution of the programs five functions and received false on each, and yet when I receive a modalState false read back and in the very next instant I receive an error saying I have an active or open modal dialog. At this point it's all just funny. I've basically just worked around it, at the end of the day I don't have to push the results to a GUI with the choice, I can simply add a checkbox or something and code it as two distinct paths. I was just hoping I could get an almost "navigation" feel where I could basically use it like a search engine.