在文字編輯中插入現在時間 - MAC

By Rebecca
at 2012-12-10T18:11
at 2012-12-10T18:11
Table of Contents
假設系統語言是繁體中文,用 Spotlight 搜尋開啓 「AppleScript 編寫程式」,
貼上底下 8 行程式碼:
set now to current date
set {year:y, month:m, day:d} to now
set t to time string of now
set m to text -2 through -1 of ("0" & m * 1)
set d to text -2 through -1 of ("0" & d)
set the clipboard to (y & "/" & m & "/" & d as string) & " " & t
delay 0.1
tell application "System Events" to keystroke "v" using command down
* 按 Cmd + S 儲存,檔名隨意 (ex: 貼上目前時間.scpt)
* 儲存至 ~/Library/Scripts/ (註1)
* 檔案格式選「工序指令」
Cmd + , 打開 AppleScript 編寫程式偏好設定,
在一般底下勾選「在選單列中顯示工序指令選單」,
在畫面上方的 Menu bar 會多一個 script 圖示,裡面有剛才儲存的 script 檔案。
在一般編輯器中點選,可以插入目前時間如 2012/12/08 16:25:37 (註2)
希望有所幫助。
註1:
可先將 script 儲存在桌面,之後在 Finder 「前往」選單底下,
按 option 鍵出現資源庫的選項,打開找到 Scripts 資料夾,把 script 檔丟進去即可。
註2:
秒數可用 text 1 through -4 去掉,不過牽涉到 12/24 小時的顯示設定,
有 AM/PM 的話可能要用 set t to text 1 through -7 of time string of now
※ 引述《kratistos (卡地拖)》之銘言:
: 想請教板友們,
: 我想要在文字編輯器(像文字編輯,Mou,nvALT)做筆記和日記,
: 想要在文字旁邊插入當下的日期和時間(如 2012/12/08 16:25),
: 請問有沒有什麼方法,像是用 Applescript 或是什麼程式,
: 可以讓我用快速鍵截取現在時間並自動貼上?
: 謝謝大家。
--
貼上底下 8 行程式碼:
set now to current date
set {year:y, month:m, day:d} to now
set t to time string of now
set m to text -2 through -1 of ("0" & m * 1)
set d to text -2 through -1 of ("0" & d)
set the clipboard to (y & "/" & m & "/" & d as string) & " " & t
delay 0.1
tell application "System Events" to keystroke "v" using command down
* 按 Cmd + S 儲存,檔名隨意 (ex: 貼上目前時間.scpt)
* 儲存至 ~/Library/Scripts/ (註1)
* 檔案格式選「工序指令」
Cmd + , 打開 AppleScript 編寫程式偏好設定,
在一般底下勾選「在選單列中顯示工序指令選單」,
在畫面上方的 Menu bar 會多一個 script 圖示,裡面有剛才儲存的 script 檔案。
在一般編輯器中點選,可以插入目前時間如 2012/12/08 16:25:37 (註2)
希望有所幫助。
註1:
可先將 script 儲存在桌面,之後在 Finder 「前往」選單底下,
按 option 鍵出現資源庫的選項,打開找到 Scripts 資料夾,把 script 檔丟進去即可。
註2:
秒數可用 text 1 through -4 去掉,不過牽涉到 12/24 小時的顯示設定,
有 AM/PM 的話可能要用 set t to text 1 through -7 of time string of now
※ 引述《kratistos (卡地拖)》之銘言:
: 想請教板友們,
: 我想要在文字編輯器(像文字編輯,Mou,nvALT)做筆記和日記,
: 想要在文字旁邊插入當下的日期和時間(如 2012/12/08 16:25),
: 請問有沒有什麼方法,像是用 Applescript 或是什麼程式,
: 可以讓我用快速鍵截取現在時間並自動貼上?
: 謝謝大家。
--
Tags:
MAC
All Comments

By Lydia
at 2012-12-12T15:52
at 2012-12-12T15:52
Related Posts
充電器的線斷掉

By Christine
at 2012-12-10T14:54
at 2012-12-10T14:54
iStat Pro和Magican顯示溫度不同(圖)

By Hedwig
at 2012-12-10T13:12
at 2012-12-10T13:12
如何刪除safari某特定網頁會記憶的字體

By Cara
at 2012-12-10T12:18
at 2012-12-10T12:18
時常出現的提示音

By Hedy
at 2012-12-10T09:38
at 2012-12-10T09:38
iTunes 半顆星評分小技巧 (不用開終端機)

By Quintina
at 2012-12-10T07:43
at 2012-12-10T07:43