set x to output volume of (get volume settings)
set current_volume to output volume of (get volume settings)
if current_volume is less than 90 then
set current_volume to 90
end if
tell application "iTunes" to pause
set volume output volume current_volume
try
say "At your service, Sir." using "Vicki"
say "Now is... " using "Vicki"
say time string of (current date) using "Vicki"
say date string of (current date) using "Vicki"
end try
set volume output volume x
- 設定變數x記錄目前的輸出音量
- 設定變數current_volume取得目前音量設定
- 如果current_volume音量值低於90的話
- 就將current_volume音量值調成90
- 將iTunes暫停(以免你的耳朵被震壞,但開機沒這煩惱,此段可刪)
- 將輸出音量調整到current_volume值
- 執行try
- 維琪:「At your service, Sir.」
- 維琪:「Now is...」
- 維琪:「時間(取得時間變數)」
- 維琪:「日期(取得日期變數)」
- 結束try
- 將輸出音量調整為最初音量值x
音量值的範圍位於0~100,通常你如果有使用鬧鐘軟體,他們都會將叮咚的聲音使用最大聲100,但我戴耳機的時候只能忍受到90,所以用這個值作為是否要調整目前音量的依據。
其實報時的句子可以利用「&」符號結合文字字串,那為什麼我還要分成多行執行呢?原因在於Vicki不知為啥在連成一串時會將時間日期逐一當成數字唸出,你就會聽到「0.6.1.3.2.0.1.0....」之類的,甚至將秒數精確唸到小數點第六位。分成多行可以讓電腦發出理想的句子,聽起來會更像真人。
你可以將儲存成應用程式,並設定開機項目(System Preferences/ Accounts/ Login items)中自動開啟。登入電腦時就會進行報時的功能,還挺有感覺的。
你可以將儲存成應用程式,並設定開機項目(System Preferences/ Accounts/ Login items)中自動開啟。登入電腦時就會進行報時的功能,還挺有感覺的。
Ref.
- CalvinX, “Volume Script,” MacScripter, 五月 8, 2005, http://macscripter.net/viewtopic.php?pid=72265.
- HexMonkey, “AppleScript System Events Volume Help,” MacRumors, 八月 19, 2005, http://forums.macrumors.com/showthread.php?t=144749.
- “AppleScript variables,” Satimage, 2008, http://www.satimage.fr/software/en/tutorial/tutorial_as2.html.
- Adam Bell, “Dates & Times in AppleScripts,” MacScripter, 七月 23, 2007, http://macscripter.net/viewtopic.php?id=24737.
Tags
電腦工具