On 3/22/07 John Delacour wrote: >If all that's needed is to copy the whole text of a pdf window and >put it in a text file, then GUI scripting can be used.
Just make sure Preview has Text Tool chosen, or add that to the script, keystroke "2" using command down Also, with larger documents, the delay might have to be longer. In a completely programmed usage, you might also want to make sure that the clipboard is empty before running this script. When I copied the script from John's message into Script Editor and ran it on a large PDF (5.7 MB) doc, Preview hadn't finished selecting the whole text when the script copied, so what was pasted into trash.txt was the script, because that was in my clipboard just before I ran the script. The longer delay took care of that, but careful data handling can save lots of grief later... John's script, slightly modified: tell application "System Events" set the clipboard to "" -- no spurious clipboard content tell process "Preview" set frontmost to true keystroke "2" using command down -- use text Tool keystroke "a" using command down delay 1 -- or longer for large docs keystroke "c" using command down end tell end tell set _text to the clipboard do shell script "cd; pbpaste > trash.txt; open -a bbedit trash.txt" HTH, - Bruce __bruce__van_allen__santa_cruz__ca__