SystemRunStartTime:=GetSystemRunStartTime()
NowTime:=SystemRunStartTime
EnvSub, NowTime, %A_Now%, Seconds
MsgBox % "系统已运行:" FormatSeconds(Abs(NowTime))
;;获取系统开机时间,返回格式同A_Now
GetSystemRunStartTime(){
ClipSaved := ClipboardAll
CommandInfo:=""
try {
Clipboard:=""
Run,% ComSpec " /C net statistics WORKSTATION | CLIP", , Hide
ClipWait
CommandInfo:=Clipboard
}
Clipboard:=ClipSaved
ClipWait
RegExMatch(CommandInfo,"20[\d]{2}(\D\d+){2}\D+\d+(\D\d+){2}",RunTime)
RunTime:=RegExReplace(RegExReplace(RunTime,"(?<=\D)(\d)(\D)|(?<=\D)(\d)$","0$1$2"),"\D")
return StrLen(RunTime)=14?RunTime:""
}
;格式化秒数为中文时间
FormatSeconds(Seconds){
Hour:=Seconds>3600?Seconds//3600:0
Minute:=Hour?(Seconds-Hour*3600)//60:Seconds//60
Second:=Hour||Minute?Seconds-(Hour*3600+Minute*60):Seconds
Return (Hour?Hour "小时":"") (Minute?Minute "分":"") (Second?Second "秒":"")
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
(Seconds-Hour*3600) 这里我用的是mod(seconds,3600),
hour := Seconds>3600?Seconds//3600:0
minutes := hour?mod(Seconds,3600)//60:Seconds//60
second := hour||minutes?mod(mod(Seconds,3600),60):seconds
随便,想到什么用什么?