Advertisement
Guest User

Untitled

a guest
Sep 30th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. on run
  2. set x to path to frontmost application as string
  3. tell application x to if exists document 1 then
  4. try
  5. try
  6. set p to path of front document -- some app use --> path of document
  7. p
  8. on error
  9. set p to file of front document -- some app use --> file of document
  10. end try
  11. my moveToTrash(p)
  12. close front document
  13. on error
  14. my speakText("can't delete this document")
  15. end try
  16. else
  17. my speakText("You have no open document in that application")
  18. end if
  19. end run
  20.  
  21. on moveToTrash(p)
  22. if p starts with "/" then -- some app return posix path
  23. set tFile to p as POSIX file as alias
  24. else -- some app return HFS path
  25. set tFile to p as alias
  26. end if
  27. tell application "Finder" to delete tFile
  28. end moveToTrash
  29.  
  30. on speakText(t)
  31. say t
  32. end speakText
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement