It is currently March 28th, 2024, 2:01 pm

New USER_LOGONTIME value for SysInfo plugin

Changes made during the Rainmeter 4.2 beta cycle.
Post Reply
User avatar
jsmorley
Developer
Posts: 22628
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.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm
Contact:

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!) ;)
User avatar
jsmorley
Developer
Posts: 22628
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.
User avatar
Beuwolf
Posts: 28
Joined: February 15th, 2020, 10:08 pm

Re: New USER_LOGONTIME value for SysInfo plugin

Post by Beuwolf »

jsmorley, this is practically the same as your System Uptime that you made in 2016 ??

Just asking because found that a couple days ago and been trying to get the Date and Time to show properly on it with no success. :oops:

But this do looks the same and was working from the start. So just thought I check if it is more or less the same thing ?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New USER_LOGONTIME value for SysInfo plugin

Post by jsmorley »

Beuwolf wrote: February 18th, 2020, 9:45 pm jsmorley, this is practically the same as your System Uptime that you made in 2016 ??

Just asking because found that a couple days ago and been trying to get the Date and Time to show properly on it with no success. :oops:

But this do looks the same and was working from the start. So just thought I check if it is more or less the same thing ?
Yes...
Post Reply