Found a solutions posted by Stefan, thanks once again. This is it for anyone who needs to know.
tell process "Preview" --this to get file name of open file in Preview
tell (1st window whose value of attribute "AXMain" is true)
set fileURL to value of attribute "AXDocument"
set windowTitle to value of attribute "AXTitle"
end tell
end tell
I receive emails that direct to a website and I can then download a PDF file which opens in Preview. What WI ould like to do is set up mail rule that will trigger applescript which will go tot the website down load the file and save it. i have got as far as opening the file but cannot get the open PDF name so I can save it. This is part of the script that deals with the opening the PDF
--It is intended this goes on the back oif the file that takes FF from email 008082012
--It will save the current issue FF
tell application "Preview"
activate
tell application "System Events"
tell process "Preview"
keystroke "p" using command down
repeat until exists sheet 1 of window 1
end repeat
tell sheet 1 of window 1
click menu button "PDF"
repeat until exists menu 1 of menu button "PDF"
end repeat
click menu item "Save as PDF." of menu 1 of menu button "PDF"
end tell
repeat until exists window "Save"
delay 0.2
end repeat
tell window "Save"
set NewFile to item 1 of window whose description is "save as"
--display dialog NewFile
keystroke "g" using {command down, shift down} --this opens box to insert folder & path
repeat until exists sheet 1
delay 0.2
end repeat
tell sheet 1
--need to set path and file name to go in box.
end tell
end tell
end tell
end tell
end tell
The save dialog box opens wi the correct file name but not the correct path. So I wanted to get the file name in the “Save As” box and add that to the right path.
Thanks
Peter