1
2
3
4
5
6
7
8
9
10
11
12
13
14
set front_app to (path to frontmost application as Unicode text)

tell app "Finder"
  reveal (POSIX file "/tmp/share.png" as alias)
  activate
  tell app "System Events" to keystroke "y" using 
  delay 8
  
  tell app "System Events" to key code 53 -- esc
  close window 1
  
end tell

tell application front_app to activate -- return focus