Your initial script was perfect. I had to make some minor changes because I might use a newer version of Foxit Reader, but it did exactly what I needed it to do. I was able to reduce most sleeps with 500ms versions to make it faster.
In case you're interested in the changes I made:
Save As uses the D shortcut in my version
The Search locations button is Button5 in my version
Cutting off .pdf and replacing it with .txt is not necessary, this is done automatically once you change the file type in the dropdown.
Thanks a lot for your script, it resolved a lot of headaches for me as Foxit seems to be the only option I found viable when trying to read that script.