Paste image to Filemaker

I have a folder with various images and a db field with the various Images path
I have a FMP script which selects for each record the related image
I have this script

   
tell application "System Events"
tell process "preview"
        keystroke "o" using command down -- open
        keystroke "c" using command down -- copy
        keystroke "w" using command down -- close window
    end tell
end tell

So far the filemaker script opens the image in Preview
However not only Preview doesn’t close the window but in the clipboard rather than the image I only find the image file name.
Inserting keystroke “a” using command down – select all the image
instead selects the whole content of the folder
Moreover
keystroke “c” using command down – copy
doesn’t copy anything
How to get a copy of the Preview file and insert it in a filemaker container field called
“image”

Thanks a lot

Hi danwan,

Maybe you need to bring Preview to the front first.

tell app "Preview" to activate

Then, add your System Events.

Edited: you can also set frontmost of process “Preview” to true.

gl,
kel