I"m trying to write an apple script to locate,copy and paste an image file.
The following code works for jpegs
and pngs
:
set thePath to "file_location"
set the clipboard to (read thePath as «class PNGf») # [1]
tell application "System Events" to keystroke "v" using command down
When I change it to a GIF
format, it doesn't work:
set thePath to "file_location"
set the clipboard to (read thePath as GIF picture) # [1]
tell application "System Events" to keystroke "v" using command down
Instead, it grabs the first frame of the GIF
, instead of the entire file.
Does anyone know what's wrong here?
This works for me on the latest version of mac OS High Sierra.
set thePath to "/Library/Desktop Pictures/Abstract.jpg"
-- set the clipboard to a file (this only works with a single file or folder)
set the clipboard to POSIX file thePath
delay 1
tell application "System Events" to keystroke "v" using command down