It is currently March 29th, 2024, 1:02 am

Sleep Command

General topics related to Rainmeter.
createRyan
Posts: 19
Joined: August 31st, 2012, 12:10 am

Sleep Command

Post by createRyan »

Setting up a button to have the computer sleep when clicked. the hibernate command is not what i want to use, it takes too long on the computer to take effect, and its a long start up. Im looking for a command that simply puts the computer to sleep, like when you close the laptop.
User avatar
thatsIch
Posts: 446
Joined: August 7th, 2012, 9:18 pm

Re: Sleep Command

Post by thatsIch »

User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Sleep Command

Post by jsmorley »

It is tricky to get a real "sleep" instead of "hibernate", but if you run this executable I just knocked out (source included) with:

LeftMouseUpAction=["#CURRENTPATH#SleepMe.exe"]

It should put your system to sleep.
SleepMe.zip
AutoIt code:

Code: Select all

#RequireAdmin

ShellExecute("powercfg",  "-hibernate off", "", "", @SW_HIDE)
Sleep(500)
ShellExecute("rundll32.exe", "powrprof.dll,SetSuspendState 0,1,0", "", "", @SW_HIDE)
You do not have the required permissions to view the files attached to this post.
User avatar
UnforgivenRevival
Posts: 310
Joined: June 7th, 2012, 2:25 am
Location: Philadelphia, PA

Re: Sleep Command

Post by UnforgivenRevival »

I use this for sleep. It doesnt go to hibernation.


LeftMouseUpAction=["#@#nircmd.exe" standby]

You will need NirCmd For this, But it was the only thing that I could find that put my computer to sleep instead of hibernation.
createRyan
Posts: 19
Joined: August 31st, 2012, 12:10 am

Re: Sleep Command

Post by createRyan »

to jsmorley, how would the code for the actual button look? can you show a quick example skin of that? and where would you save the file for the sleepme.exe?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Sleep Command

Post by jsmorley »

createRyan wrote:to jsmorley, how would the code for the actual button look? can you show a quick example skin of that? and where would you save the file for the sleepme.exe?
You could put the .exe in an @Resources\Addons folder under the folder with the skin's .ini file then use a meter like:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[MeterSleep]
Meter=String
FontSize=50
FontColor=255,0,0,255
SolidColor=0,0,0,1
StringStyle=Bold
StringEffect=Shadow
AntiAlias=1
Text="You are feeling sleepy..."
LeftMouseUpAction=["#@#Addons\SleepMe.exe"]
Or if you prefer an image button, just something like:

Code: Select all

[Rainmeter]
Update=1000

[MeterSleep]
Meter=Image
ImageName=#@#Images\Sleep.png
ImageTint=210,210,210,255
MouseOverAction=[!SetOption MeterSleep ImageTint 255,255,255,255][!UpdateMeter MeterSleep][!Redraw]
MouseLeaveAction=[!SetOption MeterSleep ImageTint 210,210,210,255][!UpdateMeter MeterSleep][!Redraw]
LeftMouseUpAction=["#@#Addons\SleepMe.exe"]
Put this:
Sleep.png
In @Resources\Images under the folder with your skin's .ini file.

https://docs.rainmeter.net/manual/skins/resources-folder/
You do not have the required permissions to view the files attached to this post.
User avatar
Virginityrocks
Posts: 478
Joined: February 26th, 2011, 10:22 pm

Re: Sleep Command

Post by Virginityrocks »

Couldn't you just use a command line and call on a .BAT to execute it? Try opening up Notepad and pasting this into it...

Code: Select all

powercfg -hibernate off
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
Then save as... set All Files, then save it as Sleep.BAT to your skin's folder.

Now run the .BAT file by putting LeftMouseUpAction=!Execute ["#SKINSPATH#\[YourSkin]\Sleep.BAT"] as a command for the sleep button.
Droptop Four
Dropdown menu bar & app launcher for Windows & Rainmeter
DkNinja49
Posts: 1
Joined: September 19th, 2020, 10:36 pm

Re: Sleep Command

Post by DkNinja49 »

Code: Select all

[Rainmeter]
Update=1000

[MeterSleep]
Meter=Image
ImageName=#@#Images\Sleep.png
ImageTint=210,210,210,255
MouseOverAction=[!SetOption MeterSleep ImageTint 255,255,255,255][!UpdateMeter MeterSleep][!Redraw]
MouseLeaveAction=[!SetOption MeterSleep ImageTint 210,210,210,255][!UpdateMeter MeterSleep][!Redraw]
LeftMouseUpAction=["#@#Addons\SleepMe.exe"]
Put this:
Sleep.png

In @Resources\Images under the folder with your skin's .ini file.

https://docs.rainmeter.net/manual/skins/resources-folder/
Hi, if I were to use the above code with an existing button along with your SleepMe.exe, where exactly do I put everything? I guess somehow I have to link that existing button to the codes above which will run the SleepMe.exe execution. Also, where do I add the SleepMe.exe if a complete Skin already exist? Sorry for all the questions, new to Rainmeter and not too sure where everything goes. Please advise!
User avatar
brax64
Posts: 172
Joined: July 8th, 2018, 8:05 pm

Re: Sleep Command

Post by brax64 »

DkNinja49 wrote: September 19th, 2020, 10:42 pm Hi, if I were to use the above code with an existing button along with your SleepMe.exe, where exactly do I put everything? I guess somehow I have to link that existing button to the codes above which will run the SleepMe.exe execution. Also, where do I add the SleepMe.exe if a complete Skin already exist? Sorry for all the questions, new to Rainmeter and not too sure where everything goes. Please advise!
Let's suppose your skin is named "GoToSleep"
If you have a standard Rainmeter installation you'll find this folder:
C:\Users\"YourUserName"\Documents\Rainmeter\Skins\GoToSleep

Inside that folder will be the GoToSleep.ini file and, probably, another folder named @Resources; if the @Resources folder doesn't exist, you MUST create it.
Open then the C:\Users\"YourUserName"\Documents\Rainmeter\Skins\GoToSleep\@Resources folder and create (if are not already there...), 2 new folder, one named Images and the other Addons.

Now copy the SleepMe.exe file inside the Addons folder and the Sleep.png file inside the Images folder.

That's all regarding the files placement.

Now if you want to modify an existing skin you must select which meter will be your "trigger" to execute the SleepMe.exe file in the way exactly as jsmorley showed in his code.

If you can't figure it out, then you'll have to post here the skin code that you want to modify so someone will surely help you to accomplish the task
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Sleep Command

Post by eclectic-tech »

DkNinja49 wrote: September 19th, 2020, 10:42 pm Hi, if I were to use the above code with an existing button along with your SleepMe.exe, where exactly do I put everything? I guess somehow I have to link that existing button to the codes above which will run the SleepMe.exe execution. Also, where do I add the SleepMe.exe if a complete Skin already exist? Sorry for all the questions, new to Rainmeter and not too sure where everything goes. Please advise!
brax64 beat me with an answer, so I will just expand it a bit...

Create your first skin shows you the steps to create a new skin. Follow those to have a basic skin open in your text editor. At that point, insert (copy and paste) the code for the sleep command from the forum post into that file and save it.

Follow brax64's steps (above) to place the exe and images.

Finally, 'Refresh All' in the Rainmeter MANAGE dialog. You will now see your new skin in the list and can load and test it.