一直找不到cmd实现睡眠的指令,直到发现psshutdown,
一个202kb,百度一下就能下载
然后将psshutdown.exe复制到以下文件夹目录
C:\Windows\System32简单说一下和休眠区别
内存供电,就是比休眠快启动,可以键盘唤醒。
待机久用休眠,短暂休息用睡眠。
睡眠
待完成上述操作后,cmd睡眠代码
psshutdown.exe-d-t0bat实现
start rundll32.exe powrprof.dll,SetSuspendState0,1,0休眠
cmd休眠代码,完全断电
shutdown-hbat休眠
start rundll32.exe powrProf.dll,SetSuspendStatepowershell 关闭休眠功能:
powercfg-h off 重启休眠功能: powercfg-hon检查休眠配置 powercfg-a锁屏
cmd锁屏代码
rundll32.exe user32.dll,LockWorkStation息屏/关闭屏幕
powerShell息屏代码
(Add-Type'[DllImport("user32.dll")]public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);'-Namea -Pas)::SendMessage(-1,0x0112,0xF170,2)bat实现息屏代码
powershell(Add-Type'[DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);'-Namea -Pas)::SendMessage(-1,0x0112,0xF170,2)参考:
PsTool的具体用法
配合AHK实现 双击息屏/睡眠
双击HOME键实现关闭屏幕
双击END键实现电脑睡眠参考:AHK手册 shutdown
~Home::If Home_key_press>0{Home_key_press+=1Return}Home_key_press=1SetTimer,Close_Func,300ReturnClose_Func:SetTimer,Close_Func,Off If Home_key_press=2{Sleep500SendMessage,0x112,0xF170,2,,Program Manager}Home_key_press=0Return~End::If End_key_presss>0{End_key_presss+=1Return}End_key_presss=1SetTimer,Sleep_Func,300ReturnSleep_Func:SetTimer,Sleep_Func,Off If End_key_presss=2{Sleep500DllCall("PowrProf\SetSuspendState","int",0,"int",0,"int",0)}End_key_presss=0Returnpower shell关闭睡眠
#关闭睡眠 powercfg-h off #检查睡眠配置 powercfg-aAHK实现睡眠
^#esc::;0x112 是 WM_SYSCOMMAND,0xF170 是 SC_MONITORPOWER;或者更直接地调用系统的电源挂起 DllCall("user32.dll\PostMessage","ptr", A_ScriptHwnd,"uint", 0x112,"ptr", 0xF170,"ptr",2);关闭显示器并睡眠return