Search code examples
applescriptosx-elcapitanquicktimeautomator

Funny issue with using automator to set quicktime window position


I'm using an applescript within automator to start a quicktime recording. When I run the applescript from automator, everything works fine, but when I run the same automator sequence as a double-clickable application, it throws an error* when it gets to this line:

tell application "System Events" to tell process "QuickTime Player" to set position of front window to {1131, 725}

Any ideas as to why?

Thanks!!

*The error is just, "The action “Run AppleScript” encountered an error"


Solution

  • You might be getting the error because your application doesn’t have permission to access GUI Scripting.

    However, you can position and resize windows in QuickTime Player without GUI scripting like this:

    tell application "QuickTime Player"
        tell window 1
            set the bounds to {100, 100, 640, 480}
        end tell
    end tell
    

    The 4 numbers that set the bounds are the x position, y position, window width, window height. So the above script tells the first window to position itself 100 pixels away from the top of the screen, 100 pixels away from the left of the screen, and to be 640 pixels wide and 480 pixels tall.

    Look in QuickTime Player’s AppleScript dictionary for the commands that enable you to start a recording with AppleScript. Open the Script Editor app and choose File > Open Dictionary and choose QuickTime Player.