使osascript与iPhone和QuickTime Player一起使用 [英] Getting osascript to work with iPhone and QuickTime Player

查看:153
本文介绍了使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 got an error: Can’t make "Gangzheng's iPhone" into type video recording device.

有没有办法使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天全站免登陆