It is currently March 28th, 2024, 9:20 pm

Cursor Click, Cursor Trail, Up Time

Get help with installing and using Rainmeter.
nyanyomen
Posts: 1
Joined: August 31st, 2020, 7:29 pm

Cursor Click, Cursor Trail, Up Time

Post by nyanyomen »

Hi, i'm new on rainmeter, can someone help me making script for these?
cursor click = how many clicks after windows login until restarted
cursor trail = how many pixels traveled after windows login until restarted
up time = how many hours elapsed after windows login until restarted

the design might be very minimalist and simple, only the text counter without any background could do, thanks!
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Cursor Click, Cursor Trail, Up Time

Post by balala »

nyanyomen wrote: August 31st, 2020, 7:34 pm cursor click = how many clicks after windows login until restarted
This can be made easily, if you want to count the clicks made on the skin. Total clicks made anywhere, is a much more complicated story. So what do you want: total number of clicks, or clicks on the skin?
nyanyomen wrote: August 31st, 2020, 7:34 pm cursor trail = how many pixels traveled after windows login until restarted
This probably requires a plugin, for instance the Mouse plugin, from NighthawkSLO. Probably not impossible, but have to work with it.
nyanyomen wrote: August 31st, 2020, 7:34 pm up time = how many hours elapsed after windows login until restarted
This is the simplest requirement, from all: the Uptime measure does exactly this: it returns the uptime, in certain format.
User avatar
Yincognito
Rainmeter Sage
Posts: 7027
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Cursor Click, Cursor Trail, Up Time

Post by Yincognito »

balala wrote: August 31st, 2020, 8:30 pm Total clicks made anywhere, is a much more complicated story.
Hmm, I don't know if it's that complicated - couldn't this be done by setting the skin's dimensions to those of the screen? The actual opaque part of the skin can be anything, of course.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Cursor Click, Cursor Trail, Up Time

Post by balala »

Yincognito wrote: September 1st, 2020, 9:13 am Hmm, I don't know if it's that complicated - couldn't this be done by setting the skin's dimensions to those of the screen? The actual opaque part of the skin can be anything, of course.
Yep, this was my idea as well, however even so, there are a lot of problems.
User avatar
Yincognito
Rainmeter Sage
Posts: 7027
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Cursor Click, Cursor Trail, Up Time

Post by Yincognito »

balala wrote: September 1st, 2020, 11:35 am Yep, this was my idea as well, however even so, there are a lot of problems.
Not a lot of problems, just one: apparently mouse isn't detected on transparent pixels, even though those pixels belong to the skin, are not Shape meter pixels, or are a part of a transparent image - like in the skin below, where only uncommenting (i.e. removing the ; from the start of the lines) the commented [Rainmeter] section that sets the SolidColor to 0,0,0,1 (aka the first 4 commented lines) works, while uncommenting the [MeterBackground] meter does not:
MouseLogon_1.0.0.rmskin
However, if one sets the SolidColor to 0,0,0,1, the skin will "cover" everything on the screen and make any operation other than manipulating the said skin impossible. Bottom line it's either one or the other: either the skin works as expected by the OP but you won't be able to do anything else but manipulating the skin, or you will be able to do things as before but the skin won't work the way the OP desires.
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Cursor Click, Cursor Trail, Up Time

Post by balala »

Yincognito wrote: September 1st, 2020, 2:12 pm Not a lot of problems, just one: apparently mouse isn't detected on transparent pixels, even though those pixels belong to the skin, are not Shape meter pixels, or are a part of a transparent image - like in the skin below, where only uncommenting (i.e. removing the ; from the start of the lines) the commented [Rainmeter] section that sets the SolidColor to 0,0,0,1 (aka the first 4 commented lines) works, while uncommenting the [MeterBackground] meter does not:
MouseLogon_1.0.0.rmskin

However, if one sets the SolidColor to 0,0,0,1, the skin will "cover" everything on the screen and make any operation other than manipulating the said skin impossible. Bottom line it's either one or the other: either the skin works as expected by the OP but you won't be able to do anything else but manipulating the skin, or you will be able to do things as before but the skin won't work the way the OP desires.
Yes. Theoretically the skin should be extended to the whole screen (as you did with the commented out SkinWidth and SkinHeight options into the [Rainmeter] section) and should be set to Click through, but unfortunately such in a case the skin although as large as the screen, still doesn't react neither to mouse movement, nor to clicks.
My guess is that this is impossible to be properly done in Rainmeter. Me at least don't see a good way. I'd recommend to nyanyomen to look for some software to do what he wants. Out there are such softwares, googling a little bit the web will reveal such tools. The are much better, probably.
User avatar
Yincognito
Rainmeter Sage
Posts: 7027
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Cursor Click, Cursor Trail, Up Time

Post by Yincognito »

balala wrote: September 1st, 2020, 3:36 pm Yes. Theoretically the skin should be extended to the whole screen (as you did with the commented out SkinWidth and SkinHeight options into the [Rainmeter] section) and should be set to Click through, but unfortunately such in a case the skin although as large as the screen, still doesn't react neither to mouse movement, nor to clicks.
My guess is that this is impossible to be properly done in Rainmeter. Me at least don't see a good way. I'd recommend to nyanyomen to look for some software to do what he wants. Out there are such softwares, googling a little bit the web will reveal such tools. The are much better, probably.
Ah, yes, why didn't I think about Click Through? :???: That's actually a good idea, because although it doesn't work the "normal" way (I guess it's because when set to Click Through the skin simply doesn't receive any mouse action whatsoever, in order to be able to control the desktop beneath it), it can temporarily be made to work by holding down the CTRL key. So, in other words, the code below will in fact work if one sets the skin to be Click Through (by right clicking on it / Settings / Click Through), but only if the user holds down the CTRL key for the period he wants to capture the mouse events (e.g. measure mouse distance / trail, count the clicks, etc.):

Code: Select all

[Variables]
MouseClicks=0
MouseDistance=0
MousePosX=0
MousePosY=0
OpaqueX=200
OpaqueY=100

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
SkinWidth=#SCREENAREAWIDTH#
SkinHeight=#SCREENAREAHEIGHT#
BackgroundMode=2
SolidColor=0,0,0,1

---Measures---

[MeasureCounter]
Measure=Calc
Formula=Counter
UpdateDivider=-1

[MeasureMouse]
Measure=Plugin
Plugin=Mouse
MouseMoveAction=[!SetVariable MouseDistance (#MouseDistance#+(Sqrt(($mouseX$-#MousePosX#)**2+($mouseY$-#MousePosY#)**2)))][!SetVariable MousePosX $mouseX$][!SetVariable MousePosY $mouseY$][!Update][!Redraw]
LeftMouseUpAction=[!SetVariable MouseClicks (#MouseClicks#+1)][!Update][!Redraw]
MiddleMouseUpAction=[!SetVariable MouseClicks (#MouseClicks#+1)][!Update][!Redraw]
RightMouseUpAction=[!SetVariable MouseClicks (#MouseClicks#+1)][!Update][!Redraw]
RelativeToSkin=0
IfCondition=(MeasureCounter=0)
IfTrueAction=[!SetVariable MousePosX $mouseX$][!SetVariable MousePosY $mouseY$]
DynamicVariables=1

[MeasureCurrentTime]
Measure=Time

[MeasureUserLogonTime]
Measure=Plugin
Plugin=SysInfo
SysInfoType=USER_LOGONTIME
UpdateDivider=-1

[MeasureUptime]
Measure=UpTime
SecondsValue=([MeasureCurrentTime:] - [MeasureUserLogonTime:])
Format="%4!i!d %3!i!h %2!i!m %1!i!s"
DynamicVariables=1

---Styles---

[BaseStyle]
X=0r
Y=0R
FontFace=Consolas
FontColor=255,255,255,255
FontSize=10
StringEffect=Shadow
FontEffectColor=0,0,0,255
AntiAlias=1

---Meters---

[MeterBox]
Meter=Shape
X=#OpaqueX#
Y=#OpaqueY#
Shape=Rectangle (0+2/2),(0+2/2),175,50,6 | StrokeWidth 2 | Stroke Color 255,255,255,255 | Fill Color 0,0,0,64
UpdateDivider=-1
DynamicVariables=1

[MeterUptime]
Meter=STRING
MeterStyle=BaseStyle
X=7r
Y=1r
MeasureName=MeasureUptime
Text="Uptime = %1"
DynamicVariables=1

[MeterMouseClicks]
Meter=STRING
MeterStyle=BaseStyle
Text="Clicks = #MouseClicks#"
DynamicVariables=1

[MeterMouseDistance]
Meter=STRING
MeterStyle=BaseStyle
Text="Trails = #MouseDistance#"
DynamicVariables=1
Then, when the user wants to resume the "normal" Click Through mode, he would simply release the CTRL key and mouse events won't be captured anymore.

Note: The above will not in any way affect counting the up time since logon, as that doesn't involve any mouse action. Only mouse actions are affected by it, and for good reason (because logically mouse events in a skin only have a meaning if one wants to do something with them in the skin, and when you do something with them you won't be able to do anything else on the normal desktop, since the skin covers the entire screen with the partially opaque self).

I'm still surprised that the plugin doesn't capture mouse events on transparent pixels, because that would have made the task possible, IMHO.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Cursor Click, Cursor Trail, Up Time

Post by balala »

Yincognito wrote: September 1st, 2020, 4:49 pm Ah, yes, why didn't I think about Click Through? :???: That's actually a good idea, because although it doesn't work the "normal" way (I guess it's because when set to Click Through the skin simply doesn't receive any mouse action whatsoever, in order to be able to control the desktop beneath it), it can temporarily be made to work by holding down the CTRL key. So, in other words, the code below will in fact work if one sets the skin to be Click Through (by right clicking on it / Settings / Click Through), but only if the user holds down the CTRL key for the period he wants to capture the mouse events (e.g. measure mouse distance / trail, count the clicks, etc.):

Then, when the user wants to resume the "normal" Click Through mode, he would simply release the CTRL key and mouse events won't be captured anymore.
Yes, but this practically makes the code to can not be used, in my opinion. Who will keep continuously hold down the control key? I guess no one.
Yincognito wrote: September 1st, 2020, 4:49 pm I'm still surprised that the plugin doesn't capture mouse events on transparent pixels, because that would have made the task possible, IMHO.
I believe Rainmeter completely ignores mouse movement / clicks on transparent parts of the skin, even with Mouse (or probably any other) plugin measures.
But there is another interesting fact I can't explain and just figured it out: if on your skin, with its original code, I set on the click through, the plugin ignores the mouse movement, EXCEPT the very first step when the mouse goes over the skin:
GIF.gif
See that when I'm hovering the mouse over the skin, the Trails value is changing once, but if I1m moving the mouse over the skin, it never changes again. If I leave the skin, then hovering the mouse over it again, Trails changes again once.
Don't have yet an explanation for this.
You do not have the required permissions to view the files attached to this post.
User avatar
Yincognito
Rainmeter Sage
Posts: 7027
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Cursor Click, Cursor Trail, Up Time

Post by Yincognito »

balala wrote: September 1st, 2020, 5:48 pmI believe Rainmeter completely ignores mouse movement / clicks on transparent parts of the skin, even with Mouse (or probably any other) plugin measures.
Yes. I should have looked in the manual, because the explanation is right there, under Usage.
balala wrote: September 1st, 2020, 5:48 pmBut there is another interesting fact I can't explain and just figured it out: if on your skin, with its original code, I set on the click through, the plugin ignores the mouse movement, EXCEPT the very first step when the mouse goes over the skin:
GIF.gif
See that when I'm hovering the mouse over the skin, the Trails value is changing once, but if I1m moving the mouse over the skin, it never changes again. If I leave the skin, then hovering the mouse over it again, Trails changes again once.
Don't have yet an explanation for this.
Yep, I might have an explanation for it, it's something related to a strange combination between click through and not having an opaque background (possibly even a particularity of Shapes in these situations, since the values change on "entering" the Shape meter). Set Click Through to off or uncomment the first 4 commented lines in the [Rainmeter] section and it will work as expected within the Shape box. Add a [!Log "Mouse Moved"] to [MeasureMouse]'s MouseMoveAction and watch the log. So I can't do anything about it since it's not something I can control, and it appears to be ingrained into the behavior of Rainmeter itself, see below.

UPDATE: Stroke the obsolete statements above, because it appears that this behavior is just the 1st (and only) mouse event permitted by click through when mouse "enters" an opaque skin. To test this, uncomment the first 4 commented lines in the [Rainmeter] section[/Strike] to make the skin opaque (while keeping the Click Through on) and then just open a window (doesn't matter which, could even be the Rainmeter Log, since it clearly shows what happens) and move the mouse in and out of that window, so that the mouse will be either on the window or on the skin. What will happen is that the mouse move event will be triggered on exiting that foreground window and entering the skin area. I believe this is the normal behavior, since although the Click Through setting disables mouse events when set to on, it still needs one single mouse event (this one) to detect when the mouse entered the skin area - so it can trigger its specific mouse event disabling. It's logical in my view, after all, to make a comparison, you can't turn off the lights if the lights are not on already, right? Same thing here: you can't trigger mouse event disabling without knowing when to do it (i.e. when on the skin), and for that you need one mouse event to tell you that. :confused:
balala wrote: September 1st, 2020, 5:48 pmYes, but this practically makes the code to can not be used, in my opinion. Who will keep continuously hold down the control key? I guess no one.
Not really. The code below toggles the click through on CTRL + Middle Click on the "skin" (well, actually the rounded box in the skin, since that's a sort of "skin simulation" so users would believe the skin is just the rounded box) and colors the stroke of the box accordingly, for the purpose of user awareness. So, you don't have to continuously hold down the CTRL key. Of course, it could be any other click instead of the middle one, or if one uses the HotKey plugin he could even set a key combination to easily trigger the toggling of click through on the skin.

Code: Select all

[Variables]
ClickThrough=0
MouseClicks=0
MouseDistance=0
MousePosX=0
MousePosY=0
OpaqueX=200
OpaqueY=100

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
SkinWidth=#SCREENAREAWIDTH#
SkinHeight=#SCREENAREAHEIGHT#
BackgroundMode=2
SolidColor=0,0,0,1
OnRefreshAction=[!ClickThrough 0]

---Measures---

[MeasureCounter]
Measure=Calc
Formula=Counter
UpdateDivider=-1

[MeasureMouse]
Measure=Plugin
Plugin=Mouse
MouseMoveAction=[!SetVariable MouseDistance (#MouseDistance#+(Sqrt(($mouseX$-#MousePosX#)**2+($mouseY$-#MousePosY#)**2)))][!SetVariable MousePosX $mouseX$][!SetVariable MousePosY $mouseY$][!Update][!Redraw]
LeftMouseUpAction=[!SetVariable MouseClicks (#MouseClicks#+1)][!Update][!Redraw]
MiddleMouseUpAction=[!SetVariable MouseClicks (#MouseClicks#+1)][!Update][!Redraw]
RightMouseUpAction=[!SetVariable MouseClicks (#MouseClicks#+1)][!Update][!Redraw]
RelativeToSkin=0
IfCondition=(MeasureCounter=0)
IfTrueAction=[!SetVariable MousePosX $mouseX$][!SetVariable MousePosY $mouseY$]
DynamicVariables=1

[MeasureCurrentTime]
Measure=Time

[MeasureUserLogonTime]
Measure=Plugin
Plugin=SysInfo
SysInfoType=USER_LOGONTIME
UpdateDivider=-1

[MeasureUptime]
Measure=UpTime
SecondsValue=([MeasureCurrentTime:] - [MeasureUserLogonTime:])
Format="%4!i!d %3!i!h %2!i!m %1!i!s"
DynamicVariables=1

---Styles---

[BaseStyle]
X=0r
Y=0R
FontFace=Consolas
FontColor=255,255,255,255
FontSize=10
StringEffect=Shadow
FontEffectColor=0,0,0,255
AntiAlias=1

---Meters---

[MeterBox]
Meter=Shape
X=#OpaqueX#
Y=#OpaqueY#
Shape=Rectangle (0+2/2),(0+2/2),175,50,6 | StrokeWidth 2 | Stroke Color (128+127*(1-#ClickThrough#)),(128+127*(1-#ClickThrough#)),(128+127*(1-#ClickThrough#)),255 | Fill Color 0,0,0,64
UpdateDivider=-1
MiddleMouseUpAction=[!SetVariable ClickThrough (1-#ClickThrough#)][!UpdateMeter #CURRENTSECTION#][!Redraw][!ClickThrough -1]
DynamicVariables=1

[MeterUptime]
Meter=STRING
MeterStyle=BaseStyle
X=7r
Y=1r
MeasureName=MeasureUptime
Text="Uptime = %1"
DynamicVariables=1

[MeterMouseClicks]
Meter=STRING
MeterStyle=BaseStyle
Text="Clicks = #MouseClicks#"
DynamicVariables=1

[MeterMouseDistance]
Meter=STRING
MeterStyle=BaseStyle
Text="Trails = #MouseDistance#"
DynamicVariables=1
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Cursor Click, Cursor Trail, Up Time

Post by balala »

Yincognito wrote: September 1st, 2020, 7:28 pm Yep, I might have an explanation for it, it's something related to a strange combination between click through and not having an opaque background (possibly even a particularity of Shapes in these situations, since the values change on "entering" the Shape meter). Set Click Through to off or uncomment the first 4 commented lines in the [Rainmeter] section and it will work as expected within the Shape box. Add a [!Log "Mouse Moved"] to [MeasureMouse]'s MouseMoveAction and watch the log. So I can't do anything about it since it's not something I can control, and it appears to be ingrained into the behavior of Rainmeter itself, see below.

UPDATE: Stroke the obsolete statements above, because it appears that this behavior is just the 1st (and only) mouse event permitted by click through when mouse "enters" an opaque skin. To test this, uncomment the first 4 commented lines in the [Rainmeter] section[/Strike] to make the skin opaque (while keeping the Click Through on) and then just open a window (doesn't matter which, could even be the Rainmeter Log, since it clearly shows what happens) and move the mouse in and out of that window, so that the mouse will be either on the window or on the skin. What will happen is that the mouse move event will be triggered on exiting that foreground window and entering the skin area. I believe this is the normal behavior, since although the Click Through setting disables mouse events when set to on, it still needs one single mouse event (this one) to detect when the mouse entered the skin area - so it can trigger its specific mouse event disabling. It's logical in my view, after all, to make a comparison, you can't turn off the lights if the lights are not on already, right? Same thing here: you can't trigger mouse event disabling without knowing when to do it (i.e. when on the skin), and for that you need one mouse event to tell you that. :confused:
Yep, you probably are right.

Yincognito wrote: September 1st, 2020, 7:28 pm Not really. The code below toggles the click through on CTRL + Middle Click on the "skin" (well, actually the rounded box in the skin, since that's a sort of "skin simulation" so users would believe the skin is just the rounded box) and colors the stroke of the box accordingly, for the purpose of user awareness. So, you don't have to continuously hold down the CTRL key. Of course, it could be any other click instead of the middle one, or if one uses the HotKey plugin he could even set a key combination to easily trigger the toggling of click through on the skin.
Yes, but unfortunately still something to be done (middle click) in order to can click on desktop elements or other things. Additionally if you set on the click through, the skin doesn't measure what it has to measure (the trail and the clicks). So, this are some inconveniences which can't be circumvented in Rainmeter. That's why I have recommended to look for a proper software to do all this.

Additional thing I recommend you to take into account:
  • Quotes are never needed in options. I suppose (hope) you, as an experimented user, know this. You've added such quotes on the Text options of the String meters.
  • Instead of working with the numeric values of the Time measures, it is a much better idea to use their TimeStamp value. That's why I'd replace the SecondsValue of the [MeasureUptime] measure with the following one: SecondsValue=([MeasureCurrentTime:TimeStamp] - [MeasureUserLogonTime:]). In this case there is no difference between the two options, but if you set a format on the Time measure, a huge difference immediately arrises. For instance see the difference below:

    Code: Select all

    [MeasureSecond]
    Measure=Time
    Format=%#S
    
    [MeterSecond]
    Meter=STRING
    X=0
    Y=0
    Padding=15,5,15,5
    FontColor=220,220,220
    FontEffectColor=0,0,0
    StringEffect=Shadow
    SolidColor=0,0,0,150
    FontSize=8
    FontFace=Segoe UI
    StringStyle=BOLD
    StringAlign=LEFT
    AntiAlias=1
    Text=Numeric: [MeasureSecond:]#CRLF#TimeStamp: [MeasureSecond:TimeStamp]
    DynamicVariables=1
    A few details: https://forum.rainmeter.net/viewtopic.php?f=5&t=30928&p=157593&p157593#p157593