It is currently February 16th, 2020, 8:48 pm

New USER_LOGONTIME value for SysInfo plugin

Changes made during the Rainmeter 4.2 beta cycle.
User avatar
jsmorley
Developer
Posts: 20225
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

New USER_LOGONTIME value for SysInfo plugin

Post by jsmorley »

New USER_LOGONTIME SysInfoType value for the SysInfo plugin.

This will return A timestamp number (number of seconds since January 1, 1601) reflecting the date and time the current user account logged onto Windows. Use with a Time measure to get a formatted string of the date/time, or subtract from the current time and use with an Uptime measure to get a formatted string of the elapsed time.

Example:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

; The account name of the current user
[MeasureUser]
Measure=Plugin
Plugin=SysInfo
SysinfoType=USER_NAME

; The current date and time
[MeasureCurrentTime]
Measure=Time

; Get the current Windows uptime in seconds and format
[MeasureUptime]
Measure=Uptime
Format="%4!i!d %3!i!h %2!i!m %1!i!s"

; Calculate the date and time Windows was restarted and format
[MeasureUptimeString]
Measure=Time
TimeStamp=([MeasureCurrentTime:]-[MeasureUptime:])
Format=%A, %B %#d, %Y at %I:%M:%S %p
DynamicVariables=1

; The date and time the current user account logged into Windows
[MeasureAccountTime]
Measure=Plugin
Plugin=SysInfo
SysInfoType=USER_LOGONTIME
UpdateDivider=-1

; Format the date and time the current user account logged onto Windows
[MeasureAccountTimeString]
Measure=Time
Group=Account
TimeStamp=[MeasureAccountTime]
Format=%A, %B %#d, %Y at %I:%M:%S %p
DynamicVariables=1

; Calculate the current user account "uptime" in seconds and format
[MeasureAccountUptime]
Measure=Uptime
Group=Account
SecondsValue=([MeasureCurrentTime:]-[MeasureAccountTime:])
Format="%4!i!d %3!i!h %2!i!m %1!i!s"
DynamicVariables=1

[MeterUptimeText]
Meter=String
FontSize=12
FontWeight=700
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
Text=System Restarted

[MeterUptimeString]
Meter=String
MeasureName=MeasureUptimeString
Y=R
FontSize=12
FontWeight=400
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1

[MeterUptimeFormat]
Meter=String
MeasureName=MeasureUptime
Y=R
FontSize=12
FontWeight=400
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
Text=Elapsed: %1

[MeterAccountText]
Meter=String
Y=10R
FontSize=12
FontWeight=700
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
DynamicVariables=1
Text=Account [MeasureUser] Logon

[MeterAccountString]
Meter=String
MeasureName=MeasureAccountTimeString
Y=R
FontSize=12
FontWeight=400
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1

[MeterAccountFormat]
Meter=String
MeasureName=MeasureAccountUptime
Y=R
FontSize=12
FontWeight=400
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
Text=Elapsed: %1
1.png
This can be of value due to the fact that Windows 10 by default does a "hybrid" shutdown, where the Windows operating system itself is "hibernated" on shutdown, and only the user session is completely terminated. This mean that when you start up again, Windows boots up much, much faster, but has the side-effect that the "Uptime" value is not reset. If you want to know when your computer was last shutdown and restarted, or when you last signed-out and back in, knowing when the user account "logged on" to Windows will tell you that. Uptime will not.
You do not have the required permissions to view the files attached to this post.
User avatar
SilverAzide
Posts: 680
Joined: March 23rd, 2015, 5:26 pm

Re: New USER_LOGONTIME value for SysInfo plugin

Post by SilverAzide »

D'oh! I just finished implementing your sample Lua DateLib function for helping with this task (along with QUSER). All that work for nuthin'! Thanks a lot!

(No, seriously, thanks! This is sooo much cleaner!) ;)
DeviantArt Gadgets More...
User avatar
jsmorley
Developer
Posts: 20225
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New USER_LOGONTIME value for SysInfo plugin

Post by jsmorley »

SilverAzide wrote:D'oh! I just finished implementing your sample Lua DateLib function for helping with this task (along with QUSER). All that work for nuthin'! Thanks a lot!

(No, seriously, thanks! This is sooo much cleaner!) ;)
quser works ok, but it has two disadvantages. The first is that it isn't included with "home" versions of Windows, and the second that it outputs in the date / time format specific to the locale of the system, so it can be hard to accurately parse. That Lua DateLib can help with that, but it all felt kinda bulky and complicated at the end of the day.

Anyway, this seems like moderately useful / interesting information about your system, and not something Windows gracefully exposes as it turns out, so I wanted to see if we could simplify it some.