[分享源码] 软件已运行时间
[分享源码] 软件已运行时间.版本 2
.支持库 EThread
.支持库 spec
.程序集 窗口程序集_启动窗口
.程序集变量 启动时间, 整数型
.子程序 __启动窗口_创建完毕
启动时间 = 取启动时间 ()
启动线程 (&运行时间, , )
.子程序 运行时间
.局部变量 a
.局部变量 当前时间
.局部变量 已运行秒数
.局部变量 提示文本, 文本型
.局部变量 分钟
.局部变量 小时
.局部变量 天
.局部变量 月
.局部变量 年
.局部变量 秒
.判断循环首 (a < 1)
当前时间 = 取启动时间 ()
已运行秒数 = (当前时间 - 启动时间) ÷ 1000
分钟 = 已运行秒数 ÷ 60
小时 = 分钟 ÷ 60
天 = 小时 ÷ 24
月 = 天 ÷ 30
年 = 月 ÷ 12
秒 = 已运行秒数 % 60
分钟 = 分钟 % 60
小时 = 小时 % 24
天 = 天 % 24
月 = 月 % 30
年 = 年 % 12
提示文本 = “已稳定运行” + 到文本 (年) + “年” + 到文本 (月) + “个月” + 到文本 (天) + “天” + 到文本 (小时) + “小时” + 到文本 (分钟) + “分钟” + 到文本 (秒) + “秒”
标签1.标题 = 提示文本
延迟 (1000)
.判断循环尾 ()
相当不错,感谢无私分享精神! 写的真的很不错
[分享源码] 软件已运行时间
在您提供的代码中,存在一些错误和不规范的表达。以下是对代码进行修正后的版本:<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辅助生成,仅供参考]
页:
[1]