有时候暂时离开一下电脑,不关显示器呢觉得又浪费电了,不手动关呢又要等一段时候屏保才启动,还是要浪费少许电。还是自己动手写一个算了。查阅了相关的资料,发现两行代码足以。
在vs2005里面建立一个vc++工程,创建一个main.cpp,然后拷贝一下代码进去。
1
#include
<
windows.h
>
2
int
WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
int
nCmdShow)
3![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
4
// Eliminate user's interaction for 500 ms
5
Sleep(500);
6![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
7
// Turn off monitor
8
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 2);
9![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
10
return 0;
11
}
12![None.gif](/Images/OutliningIndicators/None.gif)
13
![None.gif](/Images/OutliningIndicators/None.gif)
2
![None.gif](/Images/OutliningIndicators/None.gif)
3
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
![dot.gif](/Images/dot.gif)
4
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
5
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
6
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
7
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
8
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
9
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
10
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
11
![ExpandedBlockEnd.gif](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
12
![None.gif](/Images/OutliningIndicators/None.gif)
13
![None.gif](/Images/OutliningIndicators/None.gif)
编译以后生成一个文件,然后在桌面上创建一个它的快捷方式。
编辑快捷方式的属性,找到“快捷键”这一栏,设置为你需要的快捷键。我这里设置为Ctrl+Shift+Alt+F12,保存,这样需要关屏的时候只需要按以上快捷键就可以了。
![](https://i-blog.csdnimg.cn/blog_migrate/306fc6b373cfc24782d4548c9c8d41ba.jpeg)
如果你还嫌麻烦(真懒~~~),那么下载这个文件就行了:
/Files/hesicong/OneClickDisplayTurnoff.rar