让 osascript 与 iPhone 和 QuickTime Player 一起工作 [英] Getting osascript to work with iPhone and QuickTime Player

查看:20
本文介绍了让 osascript 与 iPhone 和 QuickTime Player 一起工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行这个脚本,applescript 可以很好地检测到设备

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

tell application "QuickTime Player"
    video recording devices
end tell

它给出了下面的回复

{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

它说QuickTime Player出现错误:无法将刚政的iPhone"做成类型视频录制设备.

有没有办法让applescript从iPhone记录任何东西?

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

推荐答案

我已经完成了你想做的事情,但以不同的方式,因为我也尝试过

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

我的脚本有点长,因为我想在我的 MAC 上录制我的 iphone 屏幕......所以我不得不将 QuickTime Player 设置为全屏,将鼠标指针移到屏幕外等等......

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

希望对大家有所帮助.

这篇关于让 osascript 与 iPhone 和 QuickTime Player 一起工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆