美文网首页
mac appleScript初步使用--创建文件

mac appleScript初步使用--创建文件

作者: 你与我相似 | 来源:发表于2019-10-16 17:14 被阅读0次

打开自动操作.app

image.png

添加一个工作流 ,选取应用程序,在左边栏资源库实用工具中选择 运行AppleScript `,将下方代码替换掉默认代码

image.png
image.png

代码如下:

on run {input, parameters}
    set titleStr to "请输入创建的文件名"
    set btns to {"确定"}
    display dialog titleStr buttons btns default button 1 default answer "new.txt"
    set returnRecord to the result --获取返回的record类型的值
    get the text returned of returnRecord -- 获取输入的文本
    tell application "Finder"
        set selection to make new file at (get insertion location) with properties {name:(get the text returned of returnRecord)}
    end tell
    return input
end run

关闭Automator,会提示你保存,保存到 应用程序文件夹,然后Finder 工具栏右键, 自定义, 把 New File.app 拖到工具栏的空白位置即可。点击一下,即可生成文本文件。

image.png
image.png

相关文章

网友评论

      本文标题:mac appleScript初步使用--创建文件

      本文链接:https://www.haomeiwen.com/subject/rlpumctx.html