Safety feature for buttons

Help with creating, editing & fixing problems with skins
User avatar

Safety feature for buttons

April 16th, 2018, 11:09 am
dragan
   [7 posts]

Can someone help me to make some safety feature for buttons, so some buttons cannot be pushed unless you unlock them.
For example, shutdown button should have some glassy over lock and cannot be pushed unless you remove lock. So I do not shutdown my computer by accident.

Some thing like this: http://win7gadgets.com/pc-system/control_system.html.

Image

I need code...
User avatar

Re: Safety feature for buttons

April 16th, 2018, 11:15 am
jsmorley
Developer   [17267 posts]

I find that just using LeftMouseDoubleClickAction instead of ButtonCommand or LeftMouseUpAction is enough to protect me from accidentally clicking things like this. A double-click is a much more "certain" action.

https://forum.rainmeter.net/viewtopic.php?p=100230#p100230
User avatar

Re: Safety feature for buttons

April 16th, 2018, 11:33 am
dragan
   [7 posts]

jsmorley wrote:I find that just using LeftMouseDoubleClickAction instead of ButtonCommand or LeftMouseUpAction is enough to protect me from accidentally clicking things like this. A double-click is a much more "certain" action.

https://forum.rainmeter.net/viewtopic.php?p=100230#p100230



Thank you for answer.
I saw your solution.
But it is not just shut down button, i need this for other buttons to.
Some buttons should be pushed only by me, not the kids playing and destroying my work.
And those buttons should have pin code safety if it is possible.
User avatar

Re: Safety feature for buttons

April 16th, 2018, 11:37 am
jsmorley
Developer   [17267 posts]

zip up and attach to a post here the entire skin folder that you are working with. I need all your code, and the images and such as well.

Then I can take a look and see what I can suggest.

And be clear about what you want.

Don't add things like "oh, and I want pin codes" after you have asked for help with code... I'm not a fan of "bring me a rock". ;-)
User avatar

Re: Safety feature for buttons

April 16th, 2018, 12:13 pm
dragan
   [7 posts]

jsmorley wrote:zip up and attach to a post here the entire skin folder that you are working with. I need all your code, and the images and such as well.

Then I can take a look and see what I can suggest.

And be clear about what you want.

Don't add things like "oh, and I want pin codes" after you have asked for help with code... I'm not a fan of "bring me a rock". ;-)


Relax man... This are ideas, not demands.
I like using rainmeter, it is beautiful feature.
If there is some solution for this problem ok, if not it is also ok... we will survive ;)

I do not know the code. I was combining some skins, with some small changes.
I use this skin for shot down:
https://devil-nex.deviantart.com/art/Sh ... -322181300
I was thinking is it possible to add safety lock for some buttons like this.
I was searching on google... did not find any similar thing. So here we are.
Pin code (like credit card) is just idea...
I do not know possibility of rainmeter.
User avatar

Re: Safety feature for buttons

April 16th, 2018, 12:20 pm
jsmorley
Developer   [17267 posts]

Well, there is no generic answer to this.

In general, what I think you will want is to have the ButtonCommand or LeftMouseUpAction option on the meter(s) defined to execute an InputText measure that collects some input from the user. When a button is clicked, it pops up an input that says something like "input pin number".

Then you have an IfMatch option on that InputText measure, that compares the input to some string, the pin code you want.

If that match succeeds, you use !SetOption to change the ButtonCommand or LeftMouseUpAction command to a defined #Variable# that contains the actual command you want to execute. Shutdown, restart, whatever. You can also use !SetOption to change the image of the button in some way, to indicate it is "unlocked". Perhaps have it be greyed out to start, and restore the colors when it is unlocked.

If that match fails, you just ensure the image is greyed out, and don't do anything else.
User avatar

Re: Safety feature for buttons

April 16th, 2018, 12:22 pm
balala
Rainmeter Sage   [5880 posts]

dragan wrote:I was thinking is it possible to add safety lock for some buttons like this.

jsmorley's idea is good. I also think it is possible, however I'm not sure how would you like to unlock the button.
User avatar

Re: Safety feature for buttons

April 16th, 2018, 12:51 pm
dragan
   [7 posts]

Ok, can we start with simply white transparent square which will cover buttons.
Text on it "Locked". Like on my picture.
Image
Or like windows gagdet.
http://win7gadgets.com/pc-system/control_system.html
When you click on it, it should be removed and the buttons below will be activated.

How code will be for that future on this buttons.
https://devil-nex.deviantart.com/art/Shutdown-Hibernate-andd-Reboot-322181300
User avatar

Re: Safety feature for buttons

April 16th, 2018, 1:32 pm
jsmorley
Developer   [17267 posts]

At a high level, not in the context of any particular existing skin, I might approach it like this:

ProtectButton_1.0.rmskin
(26.52 KiB) Downloaded 3 times


GIF.gif


Code: Select all

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

[Variables]
PinCode=6607

Restart=[shutdown.exe -r -t 00]
ShutdownHybrid=[shutdown.exe -s -hybrid -f -t 00]
;ShutdownFull=[shutdown -s -f -t 00]
;Sleep=[rundll32.exe PowrProf.dll,SetSuspendState 0,1,0]
;Logoff=[shutdown -l]
;Lock=[rundll32.exe User32.dll,LockWorkStation]

; Generic InputText measure to input Pin Code

[MeasureInputPin]
Measure=Plugin
Plugin=InputText
Y=37
W=200
H=18
SolidColor=200,200,200,255
FontColor=47,47,47,255
FontSize=11
AntiAlias=1
FocusDismiss=1
DefaultValue=Enter Pin Code
Command1=[!SetOption MeasureTestInput String "$UserInput$"][!UpdateMeasure MeasureTestInput]
OnDismissAction=[!SetOption MeasureTestInput String ""][!SetOptionGroup Buttons GreyScale "1"][!SetOptionGroup Blockers Hidden "0"][!UpdateMeter *][!Redraw]

; Test input against #PinCode#
; If it matches, all "blockers" are hidden and all images accept mouse clicks

[MeasureTestInput]
Measure=String
UpdateDivider=-1
IfMatch=#PinCode#
IfMatchAction=[!SetOption MeasureTestInput String ""][!UpdateMeasure MeasureTestInput][!SetOptionGroup Buttons GreyScale "0"][!SetOptionGroup Blockers Hidden "1"][!UpdateMeter *][!Redraw]
IfNotMatchAction=[!SetOption MeasureTestInput String ""][!UpdateMeasure MeasureTestInput][!SetOptionGroup Buttons GreyScale "1"][!SetOptionGroup Blockers Hidden "0"][!UpdateMeter *][!Redraw]

; Meters - Consists of one image and one "blocker" for each
; The "blockers" stops the images from seeing mouse clicks

[MeterRestart]
Meter=Image
Group=Buttons
ImageName=#@#Images\ShutdownRestart.png
GreyScale=1
LeftMouseUpAction=#Restart#
MouseLeaveAction=[!SetOptionGroup Buttons GreyScale "1"][!SetOptionGroup Blockers Hidden "0"][!UpdateMeter *][!Redraw]

[MeterBlockRestart]
Meter=Image
Group=Blockers
W=32
H=32
SolidColor=0,0,0,1
Hidden=0
LeftMouseUpAction=[!CommandMeasure MeasureInputPin "ExecuteBatch 1"]

[MeterShutdownHybrid]
Meter=Image
Group=Buttons
X=37
ImageName=#@#Images\ShutdownHybrid.png
GreyScale=1
LeftMouseUpAction=#ShutdownHybrid#
MouseLeaveAction=[!SetOptionGroup Buttons GreyScale "1"][!SetOptionGroup Blockers Hidden "0"][!UpdateMeter *][!Redraw]

[MeterBlockShutdownHybrid]
Meter=Image
Group=Blockers
X=0r
W=32
H=32
SolidColor=0,0,0,1
Hidden=0
LeftMouseUpAction=[!CommandMeasure MeasureInputPin "ExecuteBatch 1"]


It gets a tad complicated because once an InputText measure has some "value", there is no way to "unset" that value. That is why we need a separate String measure to do the "test", where we can "unset" the value of the measure.
User avatar

Re: Safety feature for buttons

April 16th, 2018, 4:44 pm
balala
Rainmeter Sage   [5880 posts]

dragan wrote:Ok, can we start with simply white transparent square which will cover buttons.
Text on it "Locked".

If you don't want to use jsmorley's (otherwise good) code, here is my approach. When you load (refresh) the skin based on the following code, you have three buttons: Shutdown, Sleep and Restart. All three are covered by a semi-transparent rectangle. When you click this rectangle, it is hidden and the below buttons can be used. Below the buttons you see the appropriate message: Lock, respectively Unlock.
When you click the Unlock message, the buttons are locked back: the semitransparent rectangle is put back (so you can't use the buttons), but you can click it again to unlock the buttons.
I didn't add the appropriate actions to the three buttons (Shutdown, Sleep and Restart), just set up a loging action (each button shows a message in the log - Shutdown, Sleep or Restart). If you find this code good enough, you have to add the appropriate action to each of them.

Code: Select all

[Rainmeter]
Update=-1

[Variables]
Lock=1

[MeasureLock]
Measure=Calc
Formula=#Lock#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!HideMeter "MeterLock"][!SetOption MeterMessage Text "Unlock"][!UpdateMeter "MeterMessage"][!Redraw]
IfFalseAction=[!ShowMeter "MeterLock"][!SetOption MeterMessage Text "Lock"][!UpdateMeter "MeterMessage"][!Redraw]
DynamicVariables=1

[StringStyle]
ClipString=1
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=CENTERCENTER
AntiAlias=1

[MeterShutdown]
Meter=STRING
MeterStyle=StringStyle
X=20
Y=20
W=40
H=40
Text=Shutdown
LeftMouseUpAction=[!Log "Shutdown"]

[MeterSleep]
Meter=STRING
MeterStyle=StringStyle
X=45r
Y=0r
W=40
H=40
Text=Sleep
LeftMouseUpAction=[!Log "Sleep"]

[MeterRestart]
Meter=STRING
MeterStyle=StringStyle
X=45r
Y=0r
W=40
H=40
Text=Restart
LeftMouseUpAction=[!Log "Restart"]

[MeterMessage]
Meter=STRING
MeterStyle=StringStyle
X=65
Y=30r
W=130
H=16
LeftMouseUpAction=[!SetVariable Lock "1"][!UpdateMeasure "MeasureLock"]

[MeterLock]
Meter=Image
SolidColor=0,0,0,100
X=0
Y=0
W=130
H=40
LeftMouseUpAction=[!SetVariable Lock "0"][!UpdateMeasure "MeasureLock"]

Return to “Help: Rainmeter Skins”



Who is online

Users browsing this forum: No registered users and 6 guests