StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
How to turn off monitor, sleep , hibernate?
Rank: Member
Groups: Approved
Joined: 4/10/2020(UTC) Posts: 22
Thanks: 8 times Was thanked: 2 time(s) in 2 post(s)
|
Hi all, I'd like to make hotkey to realize the following functions: 1、turn off the monitor 2、system sleep 3、hibernate can realize these with strokesplus.net script? thank u all! Edited by user Thursday, April 16, 2020 2:10:56 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,360 Location: Tampa, FL Thanks: 28 times Was thanked: 421 time(s) in 357 post(s)
|
1. Turn off monitor Code:sp.Pause(1); //Give some time to stop moving the mouse
sp.WindowFromClassOrTitle("", "Program Manager").SendMessageObj(0x112, 0xF170, 2); //Send monitors off message to the Program Manager
2 & 3. Probably easiest to use the PsShutdown command line utility and call it from S+ using sp.RunProgram: https://docs.microsoft.com/en-us/sysinternals/downloads/psshutdown
|
2 users thanked Rob for this useful post.
|
|
|
Rank: Member
Groups: Approved
Joined: 4/10/2020(UTC) Posts: 22
Thanks: 8 times Was thanked: 2 time(s) in 2 post(s)
|
Originally Posted by: Rob 1. Turn off monitor Code:sp.Pause(1); //Give some time to stop moving the mouse
sp.WindowFromClassOrTitle("", "Program Manager").SendMessageObj(0x112, 0xF170, 2); //Send monitors off message to the Program Manager
2 & 3. Probably easiest to use the PsShutdown command line utility and call it from S+ using sp.RunProgram: https://docs.microsoft.com/en-us/sysinternals/downloads/psshutdown Oh, thank u, Rob I now use the nircmd tool, and it works well
|
|
|
|
Rank: Advanced Member
Groups: Translators, Moderators, Approved Joined: 4/6/2020(UTC) Posts: 79 Thanks: 1 times Was thanked: 21 time(s) in 21 post(s)
|
1. This should be better Code:sp.WindowFromHandle(new IntPtr(0xffff)).PostMessageObj(0x112, 0xf170, 2);
2. Not Tested Code:sp.RunProgram('powershell.exe', "-C \"(Add-Type -MemberDefinition '[DllImport(\\\"Powrprof.dll\\\")]public static extern bool SetSuspendState(bool bHibernate,bool bForce,bool bWakeupEventsDisabled)' -Name 'SSS' -PassThru)::SetSuspendState($false,$true,$false);\"", '', 'normal', false, false, false);
3. Code:sp.RunProgram('cmd.exe', '/c shutdown /h', '', 'normal', false, false, false);
|
1 user thanked liuxilu for this useful post.
|
|
|
Rank: Member
Groups: Approved
Joined: 4/10/2020(UTC) Posts: 22
Thanks: 8 times Was thanked: 2 time(s) in 2 post(s)
|
Originally Posted by: liuxilu# 1. This should be better Code:sp.WindowFromHandle(new IntPtr(0xffff)).PostMessageObj(0x112, 0xf170, 2);
2. Not Tested Code:sp.RunProgram('powershell.exe', "-C \"(Add-Type -MemberDefinition '[DllImport(\\\"Powrprof.dll\\\")]public static extern bool SetSuspendState(bool bHibernate,bool bForce,bool bWakeupEventsDisabled)' -Name 'SSS' -PassThru)::SetSuspendState($false,$true,$false);\"", '', 'normal', false, false, false);
3. Code:sp.RunProgram('cmd.exe', '/c shutdown /h', '', 'normal', false, false, false);
thank u , liuxilu i have tested these codes 1&3 work well, but 2 does not work
|
|
|
|
Rank: Advanced Member
Groups: Translators, Moderators, Approved Joined: 4/6/2020(UTC) Posts: 79 Thanks: 1 times Was thanked: 21 time(s) in 21 post(s)
|
Tested: Code:sp.RunProgram('powershell.exe', "-C \"(Add-Type -MemberDefinition '[DllImport(\\\"Powrprof.dll\\\")]public static extern bool SetSuspendState(bool bHibernate,bool bForce,bool bWakeupEventsDisabled);' -Name 'SSS' -PassThru)::SetSuspendState($false,$true,$false);\"", '', 'hidden', false, true, false);
Edited. It should hide now. Edited by user Tuesday, May 5, 2020 7:17:13 AM(UTC)
| Reason: fix code
|
|
|
|
Rank: Member
Groups: Approved
Joined: 4/10/2020(UTC) Posts: 22
Thanks: 8 times Was thanked: 2 time(s) in 2 post(s)
|
Originally Posted by: liuxilu# Tested: Code:sp.RunProgram('powershell.exe', "-C \"(Add-Type -MemberDefinition '[DllImport(\\\"Powrprof.dll\\\")]public static extern bool SetSuspendState(bool bHibernate,bool bForce,bool bWakeupEventsDisabled);' -Name 'SSS' -PassThru)::SetSuspendState($false,$true,$false);\"", '', 'hidden', false, false, false);
@Bob, 'hidden' doesn't work. Yes , it works, but 'hidden' doesnot work
|
|
|
|
StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
How to turn off monitor, sleep , hibernate?
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close