Closed Gelo3D closed 7 years ago
Hi @Gelo3D sleep option does make sense, but I would disagree on lock, What is the use case of delaying lock operation? From your comment about lock... I don't see what is stopping your PC from downloading something while PC is locked?
Dat was just only example. Just do very simple lock pc option. Sry bro for my english, that was a reasion for had trouble understanding.
NP, I will investigate sleep mode
Is this still open and being considered? I would like to contribute.
Hello @rudinskizvonimir ticket is still open. Contribution would be welcome. Thank you.
Great, I'll start as soon as I can
I have a solution for this. The existing shutdown command in the project does not actually support a sleep. There is a way to use rundll32.exe to set the power profile to force sleep, however, if the OS has hibernation enabled then it will cause the machine to go into hibernation, not sleep. Described Here The solution seems to be using PsShutdown in the PsTools Suite. After including this in the project it works as expected. To minimize scope, I have only implemented using PsShutdown for sleep, all other features still utilize shutdown.exe. The only (minor) drawback is that the user will have to agree to the SysInternals EULA when they select sleep for the first time. After accepting the EULA, they will not see this dialog box again. If this approach sounds appropriate, I can submit a Pull Request for review.
Did you try Application.SetSuspendState method?
Simple test on my laptop showed that both hibernate (already implemented) and sleep (also called suspend, with mentioned method) worked.
We don't want to complicate and introduce unneeded dependencies. We should use SetSuspendState
and if it's not working on some PCs we can leave a comment on the web why it's not working and that it won't be handled for all edge cases.
Here is the code I've tried:
System.Windows.Forms.Application.SetSuspendState(
System.Windows.Forms.PowerState.Suspend,
force: false,
disableWakeEvent: false);
We just need "force" option to be set in there.
@rudinskizvonimir please let me know what you think about my previous comment.
@stanac I'll give it a go. I'll report back later today.
@stanac The SetSuspendedState method worked without issue. I have reworked it so that it uses this. If it is okay, I'd be ready to make a pull request at this time.
@theogjpeezy please create pull request. Thanks
implemented in #4
Add new timing option :
locked pc - example - if You download something and u wonna protect Your pc u need to example 10/15 minute to lock Your computer
sleep pc - sleep pc is best option if u need fast rest Your pc to work.