Skip to content

Instantly share code, notes, and snippets.

@qoli
Forked from kevinjalbert/mirror.scpt
Last active May 16, 2021 17:12
Show Gist options
  • Save qoli/73303f1c6c0b37e46c79d88cb79eb147 to your computer and use it in GitHub Desktop.
Save qoli/73303f1c6c0b37e46c79d88cb79eb147 to your computer and use it in GitHub Desktop.
AppleScript to Mirror Apple TV to QuickTime
set deviceName to "客廳"
readyQuickTime()
setVideoInput(deviceName)
on readyQuickTime()
tell application "QuickTime Player"
set newMovieRecording to new movie recording
delay 1
end tell
tell application "System Events" to tell process "QuickTime Player"
set frontmost to true
end tell
end readyQuickTime
on openInputsMenu()
ignoring application responses
tell application "System Events" to tell process "QuickTime Player"
click button 2 of window 1
delay 1
end tell
end ignoring
do shell script "killall 'System Events'"
end openInputsMenu
on setVideoInput(inputName)
my openInputsMenu()
tell application "System Events" to tell process "QuickTime Player"
set inputMenu to menu 1 of button 2 of window 1
set inputList to name of every menu item of inputMenu
repeat with menuItemPosition from 1 to length of inputList
if item menuItemPosition of inputList is inputName then
ignoring application responses
click menu item menuItemPosition of inputMenu
exit repeat
end ignoring
end if
end repeat
end tell
end setVideoInput
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment