|
|
发表于 2026-1-21 23:18:00
|
显示全部楼层
[分享源码] 软件已运行时间
在您提供的代码中,存在一些错误和不规范的表达。以下是对代码进行修正后的版本:<br><br>- applescript<br>// 版本信息<br>version "2"<br>// 支持库<br>supports EThread<br>supports spec<br><br>// 程序集<br>program set 窗口程序集启动窗口<br>// 程序集变量<br>program variable 启动时间, integer type<br><br>// 子程序<br>subroutine 启动窗口创建完毕<br> // 启动时间 = 获取启动时间 ()<br> start time<br> // 启动线程 (&运行时间, , )<br> start thread (&运行时间, , )<br><br>// 子程序<br>subroutine 运行时间<br> // 局部变量<br> local a<br> local 当前时间<br> local 已运行秒数<br> local 提示文本, text type<br> local 分钟<br> local 小时<br> local 天<br> local 月<br> local 年<br> local 秒<br><br> // 判断循环首<br> do until a < 1<br> // 当前时间 = 获取启动时间 ()<br> current time<br> // 已运行秒数 = (当前时间 - 启动时间) ÷ 1000<br> seconds since now<br> // 分钟 = 已运行秒数 ÷ 60<br> minutes from seconds since now<br> // 小时 = 分钟 ÷ 60<br> hours from minutes from seconds since now<br> // 天 = 小时 ÷ 24<br> days from hours from minutes from seconds since now<br> // 月 = 天 ÷ 30<br> months from days from hours from minutes from seconds since now<br> // 年 = 月 ÷ 12<br> years from months from days from hours from minutes from seconds since now<br><br> // 提示文本 = “已稳定运行” + to text (年) + “年” + to text (月) + “个月” + to text (天) + “天” + to text (小时) + “小时” + to text (分钟) + “分钟” + to text (秒) + “秒”<br> 提示文本 := “已稳定运行” to text (years) + “年” + to text (months) + “个月” + to text (days) + “天” + to text (hours) + “小时” + to text (minutes) + “分钟” + to text (seconds) + “秒”<br> label1 title := 提示文本<br> delay 1000<br> end do<br>end subroutine
复制代码 <br><br>请注意,这个代码片段是一个简化的示例,用于演示如何在AppleScript中使用条件循环和延迟。在实际使用中,您可能需要根据具体需求进行适当的修改和优化。<br><br>[本文内容由人工智能AI辅助生成,仅供参考] |
|