本文及资源最后更新时间 2021-10-02 by sky995
许多时候我们有事外出或者长时间不用电脑,但是又不能关机的情况下,如何省电呢?
电脑屏幕基本上市电脑最费电的一部分了,设置的屏保需要等待几分钟乃至半个小时才能息屏。
并且一般我们都不知道如何休眠电脑,一不小心按错了就直接关机了。
这里分享几个一键息屏+休眠的代码,大家自己编辑成bat即可直接使用了。
使用方法:
方法1+2都是新建文本,教程如下:(文件都打包了,大家下载页面下载即可。)
右键桌面新建文本文档并打开,粘贴代码,点击另存为,把下边的UTF-8改为ANSI,
文件类型改为所有文件,文件名称输入(熄屏.bat),保存over。
代码一、息屏+锁屏如下:
<span class="lit">@echo</span><span class="pln"> off echo </span><span class="lit">2</span><span class="pun">秒钟后自动熄灭屏幕</span> <span class="pun">::</span><span class="lit">3</span><span class="pun">秒延时</span><span class="pln"> ping </span><span class="pun">-</span><span class="pln">n </span><span class="lit">3</span> <span class="lit">127.1</span> <span class="pun">></span><span class="pln">nul </span><span class="pun">::息屏+休眠</span><span class="pln"> start C</span><span class="pun">:</span><span class="pln">\Windows\System32\rundll32</span><span class="pun">.</span><span class="pln">exe powrprof</span><span class="pun">.</span><span class="pln">dll</span><span class="pun">,</span><span class="typ">SetSuspendState</span> <span class="typ">Hibemate</span>
如上的3数字是2秒后自动熄屏的代码,
可以自己更改
2秒后自动熄灭屏幕这里的文字也可以自己修改
喜欢二次元的可以加一些炫酷图案颜文字进去
代码二,息屏不锁屏:
<span class="lit">@echo</span><span class="pln"> off echo </span><span class="lit">3</span><span class="pun">秒钟后自动熄灭屏幕</span> <span class="pun">并</span> <span class="pun">不锁屏</span> <span class="pun">::</span><span class="lit">3</span><span class="pun">秒延时</span><span class="pln"> ping </span><span class="pun">-</span><span class="pln">n </span><span class="lit">4</span> <span class="lit">127.1</span> <span class="pun">></span><span class="pln">nul </span><span class="pun">::息屏</span><span class="pln"> powershell </span><span class="pun">(</span><span class="typ">Add</span><span class="pun">-</span><span class="typ">Type</span> <span class="str">'[DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);'</span> <span class="pun">-</span><span class="typ">Name</span><span class="pln"> a </span><span class="pun">-</span><span class="typ">Pas</span><span class="pun">)::</span><span class="typ">SendMessage</span><span class="pun">(-</span><span class="lit">1</span><span class="pun">,</span><span class="lit">0x0112</span><span class="pun">,</span><span class="lit">0xF170</span><span class="pun">,</span><span class="lit">2</span><span class="pun">)</span> <span class="kwd">exit</span>
代码三,创建快捷方式,可以立马响应,无需等待:
1,复制如下代码:
<span class="pln">C</span><span class="pun">:</span><span class="pln">\Windows\System32\rundll32</span><span class="pun">.</span><span class="pln">exe powrprof</span><span class="pun">.</span><span class="pln">dll</span><span class="pun">,</span><span class="typ">SetSuspendState</span> <span class="typ">Hibemate</span>
将代码覆盖进快捷方式里的<目标>编辑框。
四、只关闭屏幕
代码如下创建bat文件即可:
<span class="pln">powershell </span><span class="pun">(</span><span class="typ">Add</span><span class="pun">-</span><span class="typ">Type</span> <span class="str">'[DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);'</span> <span class="pun">-</span><span class="typ">Name</span><span class="pln"> a </span><span class="pun">-</span><span class="typ">Pas</span><span class="pun">)::</span><span class="typ">SendMessage</span><span class="pun">(-</span><span class="lit">1</span><span class="pun">,</span><span class="lit">0x0112</span><span class="pun">,</span><span class="lit">0xF170</span><span class="pun">,</span><span class="lit">2</span><span class="pun">)</span>
下载地址:文件名称:电脑一键熄屏+休眠bat文件