スクリプトでスリープを抑止する。(その2)
もちろん、SetThreadExecutionState()関数を使う方法もあります。
SetThreadExecutionState.vbs
Set Excel=CreateObject("Excel.Application")
'Const ES_SYSTEM_REQUIRED=1
'Const ES_DISPLAY_REQUIRED=2
'Const ES_CONTINUOUS=-2147483648
MsgBox Hex(Excel.ExecuteExcel4Macro("CALL(""kernel32"",""SetThreadExecutionState"",""JJ"",-2147483647)")),,"Sleep抑止中(システム)"
'MsgBox Hex(Excel.ExecuteExcel4Macro("CALL(""kernel32"",""SetThreadExecutionState"",""JJ"",-2147483646)")),,"Sleep抑止中(モニター)"
'MsgBox Hex(Excel.ExecuteExcel4Macro("CALL(""kernel32"",""SetThreadExecutionState"",""JJ"",-2147483648)")),,"Sleep抑止解除"