26
N.A.N.Y. 2019 / Re: NANY 2019 - DisplayOff
« on: December 07, 2018, 03:18 AM »Welcome to the DonationCoder site, SwanKnight, and thank you for your NANY contribution.-skwire (December 05, 2018, 10:11 PM)
Thank you.
Thanks for sharing this. I have tested it and by reading your source i see that you do not trigger system, just override a powerstate.
This action kinda confuse my Windows own powersetting. (if system goes sleep mode ScreenSaver -> ScreenOff, then automatic start background jobs, those wont executed anymore with your method)-KodeZwerg (December 07, 2018, 02:58 AM)
The whole purpose of this code is turn off the display and nothing else.
Correct me if I'm wrong, but you want the PC to be also in a idle state? Frankly, I'm not sure how to even test for that.
Perhaps this article could be helpful. It goes in details about how the code works and some other API calls.
Someone suggested using PostMessage instead of SendMessage, but frankly I'm not sure if it'll make a difference or not.
Code: C# [Select]
- [DllImport("user32.dll")]
- static extern IntPtr PostMessage(int hWnd, int msg, int wParam, int lParam);
- PostMessage(-1, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);