一直找不到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_press0{Home_key_press1Return}Home_key_press1SetTimer,Close_Func,300ReturnClose_Func:SetTimer,Close_Func,Off If Home_key_press2{Sleep500SendMessage,0x112,0xF170,2,,Program Manager}Home_key_press0Return~End::If End_key_presss0{End_key_presss1Return}End_key_presss1SetTimer,Sleep_Func,300ReturnSleep_Func:SetTimer,Sleep_Func,Off If End_key_presss2{Sleep500DllCall(PowrProf\SetSuspendState,int,0,int,0,int,0)}End_key_presss0Returnpower shell关闭睡眠#关闭睡眠 powercfg-h off #检查睡眠配置 powercfg-aAHK实现睡眠^#esc::;0x112 是 WM_SYSCOMMAND0xF170 是 SC_MONITORPOWER;或者更直接地调用系统的电源挂起 DllCall(user32.dll\PostMessage,ptr, A_ScriptHwnd,uint, 0x112,ptr, 0xF170,ptr,2);关闭显示器并睡眠return
阅读完成 · 觉得有帮助?