내가 잘못하고 있는지 잘 모르겠습니다. 또한 NSTimer를 사용하는 방법을 모르겠습니다 ... 간단한 앱을 실행하고 싶습니다. Run ...을 클릭하면 스크립트의 부분은 (이Applescript OBJC의 NSTimer가 작동하지 않습니다.
current application's NSTimer's timerWithTimeInterval_target_selector_userInfo_repeats_(1, me, "runOLEDWMESerial:", missing value, yes)
on runOLEDWMESerial_(sender)
set player_active to false
set theString to "Error;00:00:00:00"
tell application "Finder"
if (get name of every process) contains "NicePlayer" then set player_active to true
end tell
if player_active then
try
tell application "NicePlayer"
if ((count of movies) is not 0) then
tell front playlist
set theName to name
set curSeconds to elapsed time as integer
set theSeconds to duration as integer
set theHours to theSeconds div 3600
set theSeconds to theSeconds - theHours * 3600
set theMinutes to theSeconds div 60
set theSeconds to theSeconds - theMinutes * 60
set theDuration to ""
if theHours > 0 then
if theHours < 10 then set theHours to "0" & theHours
set theDuration to theHours & ":"
end if
if theMinutes < 10 then set theMinutes to "0" & theMinutes
if theSeconds < 10 then set theSeconds to "0" & theSeconds
set theDuration to theDuration & theMinutes & ":" & theSeconds
set curHours to curSeconds div 3600
set curSeconds to curSeconds - curHours * 3600
set curMinutes to curSeconds div 60
set curSeconds to curSeconds - curMinutes * 60
set curTime to ""
if curHours > 0 then
if curHours < 10 then set curHours to "0" & curHours
set curDuration to curHours & ":"
end if
if curMinutes < 10 then set curMinutes to "0" & curMinutes
if curSeconds < 10 then set curSeconds to "0" & curSeconds
set curTime to curTime & curMinutes & ":" & curSeconds
set theString to theName & ";" & curTime & ";" & theDuration
end tell
end if
end tell
on error errmsg
set theString to "Error2;00:00;00:00"
end try
end if
textName's setStringValue_(theName)
textTime's setStringValue_(curTime & "/" & theDuration)
end runOLEDWMESerial_
예 나는 ... 나는 NSTimer 할려고하고, 다음 중지를 클릭하면 ... 그것은 지금까지 내가 이것을 가지고
을 중지 무엇인가 내 코드는 추악하지만, 본질적으로 이것은 주 목적 인 직렬 포트를 통해 데이터를 전송하게 될 것입니다. 그러나 지금 당장 나는 재생중인 내용을 반향하는 창을 얻으려고합니다.
그래서 runOLEDWMESerial은 실행 버튼에 묶여 있습니다. 실행 버튼을 클릭하면 루프가 한 번 트리거되지만 멈 춥니 다 ... delay (1)가있는 runOLEDWMESERIAL_ (보낸 사람) 그것도 작동하지만, 또한 UI에서 반응이 없어지고 나는 그것을 멈출 수 없다 ... 그래서 누군가가 내가 NSTimer가 작동하지 않는 이유를 이해할 수 있도록 도울 수있다.