Applescript: Help with idle and hiding from finder? I'm trying to get my script that works to do 2 things: run in the background every 60 seconds, and disappear from the finder and the dock.

Original:

tell application "System Events"
    set process_list to the name of every process
    if "QuickLookUIService" is in process_list then
        set ThePID to unix id of process "QuickLookUIService"
        do shell script "kill -KILL " &amp; ThePID

    end if

end tell


When I try the following code for idle, the script stops working. 

on idle

    tell application "System Events"
        set process_list to the name of every process
        if "QuickLookUIService" is in process_list then
            set ThePID to unix id of process "QuickLookUIService"
            do shell script "kill -KILL " &amp; ThePID

        end if

    end tell
return 60
end idle


And when I add this code to hide from finder, nothing happens. Ideas?

tell application "Finder"

    set visible of process "killQuickLook" to false

end tell
I stumbled across this link that provides a step-by-step guide to implementing the solution to this problem using launchd.

For convenience, I've copied and formatted the relevant contents of the linked page below.


  How to fix QuickLookUIService memory/CPU issues in High Sierra
  
  If you're having issues with high memory (or CPU) usage on High Sierra, this is the result of a bug with the QuickLookUIService which appears to have been introduced in that version and which unfortunately has not yet been fixed. The only workaround right now is to repeatedly force quit the quicklookuiservice. 
  
  
  Create a new file in your favourite text editor (if you use Apple's Text Edit, make sure the file is in plain text format)
  Paste the xml at the end of these steps into the file
  Rename the file to the same as what's within the &lt;string&gt; tags with a .plist extension (in my example, com.zerowidth.launched.killquicklook.plist) 
  Copy the file to your library in the LaunchAgents folder (in Finder you can use Go > Go to folder > /Users/[yourusername]/Library/LaunchAgents. You may need to type an administrator password to authorize this action
  After your next login/restart, you should find the memory issues caused by this to be back to normal. If you ever want to remove the service, just delete the plist file
  
  
  Some explanation of what this does
  
  A launch agent is a service that helps manage applications in Mac OS. In this case, we've written our own small launch agent program that kills the quicklook service repeatedly at an interval (the killall -9 -v QuickLookUIService part). The name of the service is within the  tags (you can call it what you like) and the interval is within the &lt;integer&gt; tags (in my case, 5600 seconds). Feel free to change the interval to whatever works best for you (if you set it higher, it will interfere less with your normal use of preview, but also allow the service to use more memory). As a final note, bear in mind that if you are previewing a document when the service restarts, the preview will fail (you can just preview again immediately). 

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
    &lt;dict&gt;
        &lt;key&gt;Label&lt;/key&gt;
        &lt;string&gt;com.zerowidth.launched.killquicklook&lt;/string&gt;
        &lt;key&gt;ProgramArguments&lt;/key&gt;
        &lt;array&gt;
            &lt;string&gt;sh&lt;/string&gt;
            &lt;string&gt;-c&lt;/string&gt;
            &lt;string&gt;killall -9 -v QuickLookUIService&lt;/string&gt;
        &lt;/array&gt;
        &lt;key&gt;StartInterval&lt;/key&gt;
        &lt;integer&gt;5600&lt;/integer&gt;
    &lt;/dict&gt;
&lt;/plist&gt;




Note: Expanded to answer from comment dated Dec 10 '18 at 20:29