-1
我希望能够每隔5秒运行一次applescript而不停止其他脚本的运行。我不能使用每5秒Applescript运行脚本
repeat delay 5 log theScript end repeat
,因为它会做到这一点,而不是在做任何事。有什么建议么?
我希望能够每隔5秒运行一次applescript而不停止其他脚本的运行。我不能使用每5秒Applescript运行脚本
repeat delay 5 log theScript end repeat
,因为它会做到这一点,而不是在做任何事。有什么建议么?
使用on idle
处理程序和脚本保存为应用
on idle
log theScript
return 5
end idle
在您无法使用idle
处理器的AppleScriptObjC应用程序的情况下,另一种是基础架构的NSTimer
。
property timer : missing value
on applicationWillFinishLaunching:aNotification
set timer to current application's NSTimer's scheduledTimerWithTimeInterval:5.0 target:me selector:"timerFired:" userInfo:(missing value) repeats:true
end applicationWillFinishLaunching_
on timerFired:aTimer
log "timerFired"
end timerFired
我试着把这个直接放在我的应用程序中,但它不工作。 '在空闲时 显示通知“工作” 返回5 结束空闲' –
它应该在保存为应用程序的任何脚本中工作。 – vadian
我只是把它放到我的应用程序委托脚本在Xcode并运行它。 –