作者bennyaous (fortune | cowsay)
站内MAC
标题Re: [问题] 在文字编辑中插入现在时间
时间Mon Dec 10 18:11:41 2012
假设系统语言是繁体中文,用 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 或是什麽程式,
: 可以让我用快速键截取现在时间并自动贴上?
: 谢谢大家。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.45.161.47
1F:推 kratistos:非常感谢! 12/11 13:28