How do I turn off the windows screen saver if it is running using C#?

ε祈祈猫儿з 提交于 2019-12-04 04:07:55

问题


Ok, so I found some code to check if a screensaver is running and kill it if I want to. This doesn't seem to work on Windows 7 PCs. Does anyone know how this code can be modified, or provide new code to accomplish this?

My application is designed to run in the background until a particular event occurs, and then create and display a full screen notification. This needs to be displayed even if a screen saver is currently up.

Thanks in advance for your help.


回答1:


The easiest way is to fake a mouse move event with x=y=0 by calling SendInput().




回答2:


The following question may provide some insight:

How to turn screensaver on (windows 7) by a code (in cmd)?

However, what if the machine is locked? I don't think you'll be able to display any application on top of the lock screen unless it is actually a screensaver (and even then it may not be possible)




回答3:


Assuming you don't have a password-protected screensaver: (from http://support.microsoft.com/kb/140723)

PostMessage (GetActiveWindow(), WM_CLOSE, 0, 0L);


来源:https://stackoverflow.com/questions/5474802/how-do-i-turn-off-the-windows-screen-saver-if-it-is-running-using-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!