StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
sunnyabcd  
#1 Posted : Thursday, April 16, 2020 3:53:16 AM(UTC)
sunnyabcd

Rank: Member

Reputation:

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

Rob  
#2 Posted : Friday, April 17, 2020 12:28:26 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,359
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 419 time(s) in 356 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
thanks 2 users thanked Rob for this useful post.
sunnyabcd on 4/17/2020(UTC), Faruk on 7/16/2020(UTC)
sunnyabcd  
#3 Posted : Friday, April 17, 2020 12:34:29 PM(UTC)
sunnyabcd

Rank: Member

Reputation:

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 Go to Quoted Post
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
liuxilu  
#4 Posted : Friday, April 17, 2020 12:40:44 PM(UTC)
liuxilu

Rank: Advanced Member

Reputation:

Groups: Translators, Moderators, Approved
Joined: 4/6/2020(UTC)
Posts: 79
China

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);
thanks 1 user thanked liuxilu for this useful post.
sunnyabcd on 4/17/2020(UTC)
sunnyabcd  
#5 Posted : Friday, April 17, 2020 1:51:25 PM(UTC)
sunnyabcd

Rank: Member

Reputation:

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# Go to Quoted Post
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
liuxilu  
#6 Posted : Saturday, April 18, 2020 4:21:19 AM(UTC)
liuxilu

Rank: Advanced Member

Reputation:

Groups: Translators, Moderators, Approved
Joined: 4/6/2020(UTC)
Posts: 79
China

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

sunnyabcd  
#7 Posted : Saturday, April 18, 2020 5:56:45 AM(UTC)
sunnyabcd

Rank: Member

Reputation:

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# Go to Quoted Post
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
Users browsing this topic
Guest
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.