actually, this single script should have replaced two scripts but for some reasons the scripts in actions folder have the default action "open" instead of "run". Infact, there is no action "run" for them (maybe because they are supposed to process text and files only).

on open theFile
  try
      set theFile to theFile as text
      --say 1
      tell application "System Events"
          if exists process "qlmanage" then
              do shell script "killall qlmanage"
          else
              my processthis(theFile)
          end if
      end tell
  on error e
                  tell me to activate
      display dialog e
  end try
end open

on processthis(theFile)
  set thePath to quoted form of (POSIX path of theFile)
  --say 2
  set thecmd to "qlmanage -p " & thePath
  do shell script thecmd & "> /dev/null 2>&1 &"
  --say 3
  set closepath to "path to:this:script" as alias
  --say 4
  return closepath
end processthis

Reply via email to