I've been looking for some information: If you can edit the dialog.
I know that with this command can invoke, but I have no idea how to edit the text boxes and then search and replace.
app.executeMenuCommand ('Find and Replace')
The reason I chose this method is that preserves text formats and all text searches.
Perhaps this issue will be useful for you:
And extension panel, that I use: https://github.com/dumbm1/ai_re