提取系统开机时间

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 "秒":"")
}

给TA捐赠
共{{data.count}}人
人已捐赠
其他案例

获取进程文件路径方法留档

2022-3-4 15:07:59

其他

调用系统颜色选取框

2022-3-4 15:08:53

2 条回复 A文章作者 M管理员
  1. ahkjoo

    (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

    • 蜜獾哥

      随便,想到什么用什么?

个人中心
购物车
优惠劵
有新私信 私信列表
搜索