KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Can I put the computer to sleep through Dragon?
Topic Summary:
Created On: 03/11/2021 04:03 AM
Status: Post and Reply
Linear : Threading : Single : Branch
 Can I put the computer to sleep through Dragon?   - Anandits - 03/11/2021 04:03 AM  
 Can I put the computer to sleep through Dragon?   - Lunis Orcutt - 03/11/2021 10:58 AM  
 Can I put the computer to sleep through Dragon?   - noblemd - 03/11/2021 12:41 PM  
 Can I put the computer to sleep through Dragon?   - Anandits - 03/15/2021 06:24 AM  
 Can I put the computer to sleep through Dragon?   - monkey8 - 03/15/2021 04:19 PM  
Keyword
 03/11/2021 04:03 AM
User is offline View Users Profile Print this message

Author Icon
Anandits
Senior Member

Posts: 147
Joined: 03/25/2019

Is it possible to use a Dragon command to put the computer to sleep? For some reason closing the lid of my laptop doesn't put it to sleep, even though that setting is on.

I find it tedious having to use WIN X, U, S, manually.


I can't seem to make a Dragon command using the Windows key.

Or maybe there is already a command that puts the computer to sleep? 

 

 03/11/2021 10:58 AM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 39487
Joined: 10/01/2006

In KnowBrainer we say Hibernate Windows (deep sleep). If you're not using KnowBrainer, you can use the following Advanced-Scripting command

 

Sub Main
ShellExecute "shutdown /h"
End Sub


-------------------------

Change "No" to "Know" w/KnowBrainer 2020
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ex 1



 03/11/2021 12:41 PM
User is offline View Users Profile Print this message

Author Icon
noblemd
Junior Member

Posts: 29
Joined: 08/09/2019

See:
https://docs.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-setsuspendstate?redirectedfrom=MSDN

Advanced Scripting - use your own command name...
---------------------------------------------------------------
'#Language "WWB-COM"

Option Explicit

Declare Function SetSuspendState Lib "PowrProf" (ByVal Hibernate As Integer, ByVal ForceCritical As Integer, _
     ByVal DisableWakeEvent As Integer) As Integer

Sub Main
    SetSuspendState(0, 0, 0) 'Sleep without forcing and ?no? wake events disabled
    ' SetSuspendState(1, 0, 0) 'Hibernate without forcing and ?no? wake events disabled
End Sub

 

 



-------------------------

Michael Noble
-------------------------
Using $20 USB Mic on adjustable arm ($30 total cost - 99.9% recognition). 


DPI 15.61.200.010 - Windows 11 Pro for Workstations Build 22499.1010 / MS Office 2021 LTSC



 03/15/2021 06:24 AM
User is offline View Users Profile Print this message

Author Icon
Anandits
Senior Member

Posts: 147
Joined: 03/25/2019

Thank you, Lunis. Yes, I'm using KnowBrainer. However, I don't want the computer to hibernate at that point, I wanted to go to sleep only. I experimented with editing your command changing the /h to /s, but that actually cause my computer to shut down.

And Michael, thank you for that script. I created it and it does turn off my computer, but it is still hibernating instead of sleeping. If I put the computer to sleep normally (either by closing the lid, or by pressing Win x, u, s, , I can open the lid and it wakes up again. But after this command I have to use the on switch to get going again.



 03/15/2021 04:19 PM
User is offline View Users Profile Print this message

Author Icon
monkey8
Top-Tier Member

Posts: 3852
Joined: 01/14/2008

Originally posted by: Anandits And Michael, thank you for that script. I created it and it does turn off my computer, but it is still hibernating instead of sleeping.

 

 

You need to use Michael's script but I would try:

 

SetSuspendState (0,1,0) to force even though the Windows API documentation says the force parameter has no effect

 

However using the above you can have problems putting the computer into sleep mode if hibernation is turned on. So turn it off, to do that go to the Start Menu and open an elevated Command Prompt by typing cmd.exe, right clicking and choosing Run as administrator. Type the following command:

 

powercfg -hibernate off


You should then find that Michael's command or the force option will work fine



-------------------------



Statistics
32213 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 1 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 349 guests browsing this forum, which makes a total of 350 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2022 FuseTalk™ Inc. All rights reserved.