Applescript 编辑器自动运行
我可以制作一个苹果脚本,当我放入闪存驱动器时自动运行吗?我希望能够做到这一点,这样当我将闪存驱动器放入学校的计算机中时,我可以自动播放我的演示文稿以节省时间,这样我就不必在全班同学面前浏览所有文件。我们在学校使用 Mac,我也有一台 Mac。
Can I make an apple script that auto runs when I put in my flash drive? I want to be able to do this so that when I put my flash drive in the computer at school I can make my presentation automatically play to save time and so i don't have to go through all my files in front of the class. We use macs at school and I have a mac.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当驱动器插入时,无法使用普通的 AppleScript 接收事件。
您可以做的是创建一个轮询计时器,以指定的时间间隔检查驱动器:
我随手写下了这一点,但我还没有测试过它,但沿着这些思路的东西应该有效。
delay 5
告诉脚本在再次轮询之前等待 5 秒,请更改此值以满足您的需要。我以前没有尝试过使用 AppleScript 进行类似的操作,因此它可能会占用资源。There's no way using plain AppleScript to receive events when a drive is plugged in.
What you could do is create a poll timer that checks for the drive at a specified interval:
I wrote that off the top of my head, and I haven't tested it, but something along those lines should work.
delay 5
tells the script to wait 5 seconds before polling again, change this to suit your needs. I haven't tried anything like this with AppleScript before so it may be taxing on resources.您可以激活文件夹操作苹果脚本来监视新附加的卷。
复制脚本/Library/Scripts/Folder Action Scripts/add - new itemalert.scpt并修改副本以打开您的演示文稿或您拥有的内容。
通过/Library/Scripts/Folder Actions/Configure Folder Actions(指向/System/Library/CoreServices/Folder Actions Setup.app的链接)激活脚本:
You can activate a Folder Action applescript to watch for newly attached volumes.
Duplicate the script /Library/Scripts/Folder Action Scripts/add - new item alert.scpt and modify the copy to open your presentation or what-have-you.
Activate the script via /Library/Scripts/Folder Actions/Configure Folder Actions (a link to /System/Library/CoreServices/Folder Actions Setup.app):