I am trying to write a script that toggles on/off a quicklook window from within a particular program (e.g., TextEdit). The script will be run using a global hotkey. The following code works fine to display the window but I need a command to remove the window. Thanks.
property test : true
set thefile to "/Path/to/image.png"
if (test) then
set test to false
QuickLook(thefile)
else
set test to true
-- need a command to dismiss the quicklook window
end if
on QuickLook(thefile)
do shell script "qlmanage -p " & quoted form of thefile & " >& /dev/null &"
end QuickLook
I’m sure there is a better way, but this will work:
property test : false
set thefile to "/Users/aaon/Desktop/Screen shot 2010-11-02 at 7.31.52 AM.png"
if (test) then
set test to false
QuickLook(thefile)
else
set test to true
-- need a command to dismiss the quicklook window
set getPID to (do shell script "ps -A | grep qlmanage") as string
set {TID, text item delimiters} to {text item delimiters, space}
set thePID to text item 1 of getPID
set text item delimiters to {""}
do shell script "kill -9 " & thePID
end if
on QuickLook(thefile)
do shell script "qlmanage -p " & quoted form of thefile & " >& /dev/null &"
end QuickLook