3
votes

I am trying to start and hide quicktime player, start recording my iPhone screen for some duration and save the output on the desktop with file name "hello" with the below script

on run
    set filePath to (path to desktop as text) & "hello.mov"
    set f to a reference to file filePath

    startVideoRecording(f)

end run

on startVideoRecording(f)

    tell application "QuickTime Player"
        activate
        tell application "System Events"
            keystroke "h" using command down
        end tell
        set newMovieRecording to new movie recording
        set camera to "Prabhu Konchada's iPhone"
        tell newMovieRecording
            set camera to "Prabhu Konchada's iPhone"
            start
        end tell
        delay (10)
        pause
        save newMovieRecording in f
        stop
        close newMovieRecording
    end tell
end startVideoRecording

To hide quicktime player I tried :

  1. tell application "System Events" to tell process "QuickTime Player" to keystroke "h" using command down.
  2. tell application "Finder" set visible of process "QuickTime Player" to false end tell

  3. tell application "System Events" set frontProcess to first process whose frontmost is true set visible of frontProcess to false end tell

The above 3 methods didn't serve my purpose and I don't want this quicktime all over my screen or visible in my DOCK ...

2

2 Answers

3
votes
tell application "System Events"
set visible of application process "QuickTime Player" to false
end tell
1
votes

set the bounds of the front window to an "impossible" value and delete the activate line

on run
    set filePath to (path to desktop as text) & "hello.mov"
    set f to a reference to file filePath

    startVideoRecording(f)

end run

on startVideoRecording(f)

    tell application "QuickTime Player"
        set newMovieRecording to new movie recording
        set bounds of window 1 to {-3000, 0, 100, 100}
        set camera to "Prabhu Konchada's iPhone"
        tell newMovieRecording
            set camera to "Prabhu Konchada's iPhone"
            start
        end tell
        delay (10)
        pause
        save newMovieRecording in f
        stop
        close newMovieRecording
    end tell
end startVideoRecording