It is currently November 26th, 2022, 6:46 pm

UpTimeUser

Skins that monitor system information
User avatar
jsmorley
Developer
Posts: 22551
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

UpTimeUser

Post by jsmorley »

One of the differences between Windows 7 and 8/10 is how "shutdown" is handled.

In Windows 8 and 10, when you do a normal system "shutdown", a hybrid "hibernate / shutdown" is done. What this means is that the user session, Windows Explorer and all running applications, are "shut down", but the core of Windows, the OS itself, is "hibernated". On a system "restart" on the other hand, the entire user session and OS are completely restarted.

Nothing wrong with this, it's a good thing. When you "shutdown" your computer, it restarts and gets running about twice as fast in Win10 as it does in Win7. It doesn't have to fully "stand up" the OS every time.

However, the long and the short of this is that the value for System Uptime is not reset when you shutdown the computer, only when you do a restart.

While knowing when a full restart of the OS was done is of value, it might also be of value to know when anything restarts just the user session, like when the computer is "shutdown" or you "sign out" of your user account. The reason this might be of interest is that this is a more reliable indication of when all your applications, and Windows Explorer, were last restarted.

Anyway, there is a little utility, quser.exe, included in Win7 - Win10, that can help with this.

Note that this utility only ships with the "Professional" versions of Windows or higher.
This entire thing will not work on Windows XP, nor on any version of Win7/Win8.1/Win10 "basic" or "home" editions.


Here is a little skin that demonstrates how you might use this utility:

Skin:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!CommandMeasure MeasureUserLoginTime "Run"] 

; Short Date: M/d/yyyy
; Short Time: h:mm tt
 
 [MeasureGetUserName]
Measure=Plugin
Plugin=SysInfo
SysInfoType=USER_NAME

[MeasureSystemUpTime]
Measure=UpTime

[MeasureCurrentTime]
Measure=Time

[MeasureCurrentSeconds]
Measure=Time
Format=%#S
MinValue=0
MaxValue=59

[MeasureSystemDiff]
Measure=Time
TimeStamp=([MeasureCurrentTime:] - [MeasureSystemUpTime:])
Format=%a, %b %#d - %#I:%M %p
DynamicVariables=1
OnUpdateAction=[!CommandMeasure MeasureParseSeconds """ParseSeconds([MeasureSystemUpTime:], "MeterSystemRestart")"""]

[MeasureUserLoginTime]
Measure=Plugin
Plugin=RunCommand
Parameter=quser "[MeasureGetUserName]"
State=Hide
OutputType=ANSI
DynamicVariables=1
RegExpSubstitute=1
Substitute="(?si).*  (.*)$":"\1","#CRLF#":""
FinishAction=[!EnableMeasureGroup UserTimes]

[MeasureUserFormat]
Measure=Time
Group=UserTimes
TimeStamp=[MeasureUserLoginTime]
TimeStampFormat=%#m/%#d/%Y %#I:%M %p
Format=%a, %b %#d - %#I:%M %p
DynamicVariables=1
Disabled=1

[MeasureUserDiff]
Measure=Time
Group=UserTimes
TimeStamp=([MeasureCurrentTime:timestamp] - [MeasureUserFormat:timestamp])
DynamicVariables=1
Disabled=1
OnUpdateAction=[!CommandMeasure MeasureParseSeconds """ParseSeconds([MeasureUserDiff:timestamp], "MeterUserLogin")"""]

[MeasureParseSeconds]
Measure=Script
Group=UserTimes
ScriptFile=#CURRENTPATH#UpTimeUser.lua
Disabled=1
UpdateDivider=-1

[MeterBackground]
Meter=Image
W=(Max([MeterSystemRestart:W],[MeterUserLogin:W]) + 20)
H=167
SolidColor=20,30,40,255
DynamicVariables=1

[MeterAnimationBack]
Meter=Roundline
X=10
Y=5
W=20
H=20
LineStart=9
LineLength=10
LineColor=252,245,204,255
StartAngle=(Rad(270))
RotationAngle=(Rad(360))
AntiAlias=1
Solid=1

[MeterAnimation]
Meter=Roundline
MeasureName=MeasureCurrentSeconds
X=10
Y=5
W=20
H=20
LineStart=0
LineLength=9
LineWidth=2
LineColor=252,245,204,255
StartAngle=(Rad(270))
RotationAngle=(Rad(360))
AntiAlias=1
Solid=0

[MeterHeader]
Meter=String
X=5R
Y=5
FontSize=14
FontColor=252,245,204,255
SolidColor=0,0,0,1
AntiAlias=1
InlineSetting=Size | 16
InlinePattern=◔
Text=System Uptime

[MeterSystemRestart]
Meter=String
MeasureName=MeasureSystemDiff
X=10
Y=10R
FontSize=12
FontColor=204,234,252,255
SolidColor=0,0,0,1
AntiAlias=1
InlineSetting=Size | 14
InlinePattern=^(.*)#CRLF#
InlineSetting2=Color | 159,212,245,255
InlinePattern2=^(.*)#CRLF#
Text=Windows#CRLF#%1#CRLF#
 
[MeterUserLogin]
Meter=String
MeasureName=MeasureUserFormat
X=10
Y=10R
FontSize=12
FontColor=208,252,204,255
SolidColor=0,0,0,1
AntiAlias=1
DynamicVariables=1
InlineSetting=Size | 14
InlinePattern=^(.*)#CRLF#
InlineSetting2=Color | 171,245,159,255
InlinePattern2=^(.*)#CRLF#
Text=[MeasureGetUserName]#CRLF#%1#CRLF#
Lua:

Code: Select all

function Initialize()

end

function ParseSeconds(inputSeconds,meterName)

	local days, hours, minutes, seconds = FormatSeconds(tonumber(inputSeconds))

	SKIN:Bang('!SetOption', meterName, 'Postfix', days..'d '..hours..'h '..minutes..'m '..seconds..'s ')
	SKIN:Bang('!UpdateMeter', '*')
	
end

function FormatSeconds(secondsArg)

	local days = math.floor(secondsArg / 86400)
	local hours = math.floor((secondsArg - days * 86400) / 3600)
	local minutes = math.floor((secondsArg - days * 86400 - hours * 3600) / 60)
	local seconds = math.floor(secondsArg - days * 86400 - hours * 3600 - minutes * 60)
	
	return days, hours, minutes, seconds
	
end
1.jpg

Get the .rmskin here:
UpTimeUser_1.0.rmskin
--------
Important:


This works for me on my US-English system, with the default time format settings of:
Short Date: M/d/yyyy
Short Time: h:mm tt

So quser.exe displays the date and time as: 1/17/2016 at 12:17 PM
You can check this by opening a Command Prompt window, and typing quser YourAcccountName.
2.jpg
If your system is using a different date and time format, you are probably going to need to play with the TimeStampFormat=%#m/%#d/%Y %#I:%M %p in [MeasureUserFormat] to get it to work at all, and likely the Format=%a, %b %#d - %#I:%M %p in both [MeasureSystemDiff] and [MeasureUserFormat] to get it to display in the format you want.

https://docs.rainmeter.net/manual/measures/time/
You do not have the required permissions to view the files attached to this post.