Getting osascript to work with iPhone and QuickTime Player

寵の児 提交于 2019-12-13 03:19:55

问题


I run this script and applescript can detect the devices just fine

tell application "QuickTime Player"
    video recording devices
end tell

It gives a the reply below

{screen compression preset "FaceTime HD Camera" of application "QuickTime Player", screen compression preset "Gangzheng's iPhone" of application "QuickTime Player"}

But when I run my actual script

tell application "QuickTime Player"
    video recording devices
    set newMovieRecording to new movie recording
    tell newMovieRecording
        set current camera of newMovieRecording to "Gangzheng's iPhone"
        set current microphone of newMovieRecording to "Gangzheng's iPhone"
        start
    end tell
end tell

it says QuickTime Player got an error: Can’t make "Gangzheng's iPhone" into type video recording device.

Is there a way to make applescript record anything from iPhone?


回答1:


I had accomplished what you want to do, but in a different way because I also tried with

set current camera of newMovieRecording to "Gangzheng's iPhone"

but had no luck.... So here is my script for setting a camera

tell application "System Events" to tell process "QuickTime Player"
    #Set volume to 100%
    click button 1 of window 1
    #To open dialog to show available cameras
    click button 3 of window 1
    #To select our device
    click menu item "Gangzheng's iPhone" of menu 1 of button 3 of window 1
end tell

My script was a bit longer because I wanted to record the screen of my iphone at my MAC... So I had to set QuickTime Player to full screen, move mouse pointer outside the screen and so on...

tell application "Finder"
    set bigBounds to (get bounds of window of desktop)
end tell
tell application "QuickTime Player"
    activate
    start
    #Start new recording cmd + option + N
    tell application "System Events" to key code 45 using {option down, command down}
    set iBounds to (get bounds of front window) 
    if bigBounds = iBounds then
        delay 1 
    else
        #Full screen only if is not already at full screen control + cmd + F        
        tell application "System Events" to key code 3 using {control down, command down}
        delay 1 
    end if
    tell application "System Events" to tell process "QuickTime Player"                 
        #Set volume to 100%
        click button 1 of window 1      
        #To open dialog to show available cameras
        click button 3 of window 1      
        #To select our device
        click menu item "iPhone de User" of menu 1 of button 3 of window 1  
    end tell
    #To move mouse to the right side of the screen
    set mouseToolsPath to "/Users/Shared/MouseTools"
    set x to (item 3 of bigBounds) - 1
    set y to (item 4 of bigBounds) / 2
    #Por si el archivo no existe...
    try
        do shell script quoted form of POSIX path of mouseToolsPath & " -x " & (x as text) & " -y " & (y as text)
    on error errMsg number errNum
        display dialog "An unknown error occurred:  " & errNum as text
    end try
end tell

Hope it is helpful to someone.




回答2:


barbudito, can you try this?

tell application "QuickTime Player"
    get video recording device "Gangzheng's iPhone"
    set newMovieRecording to new movie recording
    tell newMovieRecording
        start
        delay 10
        do shell script "env"
        pause
        save newMovieRecording in "/Users/pmlg673f/Movies/test.mov"
        stop
        close newMovieRecording
    end tell
end tell


来源:https://stackoverflow.com/questions/45228743/getting-osascript-to-work-with-iphone-and-quicktime-player

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!