1

Is there a way to resize and reposition a quick look window with AppleScript? I have an AppleScript that will do this with any app, but I do not know what the quick look app is called.

I have tried QuickLook, Quick Look, and QL.

3
  • I may be wrong, but I don’t think QuickLook is an app but rather a function of the Finder App. You might try looking in the AppleScript Finder Library.
    – bjbk
    Nov 30, 2017 at 4:13
  • 1
    QuickLook is a Framework and its app name is quicklookd.app and its has scripting terminology property is false. Its displayed name property is Quick Look Helper and identifier property is com.apple.QuickLookDaemon. I do not believe you'll be able to do much with it. Nov 30, 2017 at 4:29
  • My two cents to this is that I've never been able to resize it with any window manager. The one I currently use: Moom can only move it around. So maybe there is a chance that you could position it with applescript.
    – Joonas
    Nov 30, 2017 at 7:28

2 Answers 2

1

Here's a little AppleScript I wrote to resize and reposition the Quick Look window so that it occupies the right one-third of the screen:

    tell application "System Events"
        if not (exists window "Quick Look") of process "Finder" then
            activate application "Finder"
            keystroke "y" using command down
        end if
    end tell

    tell application "System Events" to tell process "Finder"
        if not (exists window "Quick Look") then ¬
            with timeout of 5 seconds
                repeat until (exists window "Quick Look")
                end repeat
            end timeout

        set [W, H] to size of scroll area 1 --(desktop)

        tell window "Quick Look"
            set [_w, _h] to size
            set [_x, _y] to position

            set position of it to [W * 2 / 3, 0]
            set size of it to [W * 1 / 3, H]
        end tell
    end tell

This requires that the appropriate application from within which this script is run (e.g. Script Editor, Keyboard Maestro, Better Touch Tool, etc.) is given assistive accessibility permissions, which (in High Sierra) you can grant in System Preferences > Security & Privacy > Privacy > Accessibility.

1
  • @David if this answer worked for you, please mark it as the correct answer, which will help other people who might Google for the same problem, plus give me some brownie points. Thanks.
    – CJK
    Dec 22, 2017 at 11:36
0

your solution worked for me! I tried upvoting it to give you cred, but I'm a newbie. Also I modified it a bit as follows to meet my needs.

tell application "System Events"
    if not (exists window "Quick Look") of process "Finder" then
        activate application "Finder"
        keystroke "y" using command down
    end if
end tell

tell application "System Events" to tell process "Finder"
    if not (exists window "Quick Look") then ¬
        with timeout of 1 second
            repeat until (exists window "Quick Look")
            end repeat
        end timeout

    set [W, H] to size of scroll area 1 --(desktop)

    tell window "Quick Look"
        set [_w, _h] to size
        set [_x, _y] to position

        set position of it to [25, 50]
        set size of it to [W - 50, H - 100]
    end tell
end tell

I set the Y position to 50 because I think setting it to 0 makes the script try to put the Quick Look window behind the menu bar, and I don't think that's allowed. I'd like to tweak this a little more, but I don't know how to contact you directly or if you will even see this since it is a year later. So let me know if you see this, Thanks.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .