0
我做了一個監聽某個端口的applescript。當它收到「開始」時,計算機開始從網絡攝像頭錄製,當它收到「停止」時,它停止錄製。正常退出applescript運行終端nc命令
現在的問題是,我總是不得不強制退出這個應用程序。由於重複聲明?有沒有辦法繞過這個?我讀了一些關於閒置處理程序的內容,但對於我的應用程序繼續運行(沒有用戶點擊等)非常重要。
set recording to 0
repeat
set test to (do shell script "nc -l 2700") as string
if test = "start" and recording = 0 then
tell application "QuickTime Player"
activate
new movie recording
document "Movie Recording" start
set recording to 1
delay 2
end tell
else if test = "stop" and recording = 1 then
tell application "QuickTime Player"
document "Movie Recording" stop
set pad to path to desktop folder as string
set naam to (do shell script "date +%s") as integer
set extension to ".mov"
set all to pad & naam & extension
export document "Untitled" in file all using settings preset "720p"
delay 1
close document "Untitled" saving no
set recording to 0
end tell
end if
end repeat
除了「開始」和「停止」之外,您不能只添加一個「退出」消息嗎? –