我如何写的AppleScript,这将使我每小时弹出警报 [英] How do I write Applescript that will give me an hourly popup alert

查看:873
本文介绍了我如何写的AppleScript,这将使我每小时弹出警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何让我的计算机(Mac OS X)每隔一小时上的弹出警报。我想这写AppleScript中是pretty简单,但我没有经验的AppleScript。谢谢

I am wondering how to have a popup alert on my computer (Mac OS X) every hour. I figured writing this in Applescript would be pretty simple but I have no Applescript experience. Thanks

推荐答案

有关AppleScript的中定期做事的基本处理程序是空闲处理器。

The basic handler for doing things on a regular basis in AppleScript is the idle handler.

on idle
 display dialog "Go back to work" buttons "Work Harder" default button "Work Harder"
 return 3600
end idle

当你开始pressing的按钮后,应用程序,然后每3600秒这个脚本会弹出一个对话框。无论数量空闲处理器的回报将是下一个空闲事件被触发前的秒数。

This script will pop up a dialog box when you start the application and then every 3,600 seconds after pressing the button. Whatever number the idle handler returns will be the number of seconds before the next idle event is triggered.

如果您希望它是上半小时,而不是每六十分钟,你会想要闲置脚本返回不同数量的秒,也许60,然后检查一下,如果你在正确的小时的一部分。

If you want it to be on the half-hour and not every sixty minutes, you'd want the idle script to return a different number of seconds, perhaps 60, and then check to see if you're at the right part of the hour.

on idle
 if the minutes of the (current date) is 30 then
  display dialog "Go back to work" buttons "Work Harder" default button "Work Harder"
 end if
 return 60
end idle

这只会在半对话框。 (Unix一样,的AppleScript的当前日期的概念包括当前的时间。)

This will only display the dialog at half past. (Like Unix, AppleScript’s concept of the current date includes the current time.)

在每一种情况下,你想的AppleScript编辑器中保存为应用程序和保持开放,以让它响应空闲事件,而不是运行后仅狭路相逢。而且你可以将应用程序添加到您的登录项中的账户系统preference的名单,使其在登录时自动运行。

In each case, you want to save in AppleScript Editor as "Application" and "Stay Open" in order to have it respond to idle events instead of just quitting after running. And you can add the application to your list of "Login Items" in the "Accounts" system preference to make it run automatically when you log in.

这篇关于我如何写的AppleScript,这将使我每小时弹出警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆