import win.ui;
/*DSG{{*/
var winform = win.form(text="关闭显示器";right=759;bottom=469)
winform.add(
button={cls="button";text="关闭显示器";left=414;top=273;right=639;bottom=343;z=1}
)
/*}}*/

winform.button.oncommand = function(id,event){
    
    //延时异步执行，避免显示器刚关掉又被唤醒
    winform.setTimeout( 
        function(){ 
            //用:User32.SendMessage会卡，改用异步的::User32.PostMessage
            ::User32.PostMessage( 0xFFFF/*_HWND_BROADCAST*/ ,0x112/*_WM_SYSCOMMAND*/, 0xF170/*_SC_MONITORPOWER*/ ,2);
        },200 //给一点延时，万一鼠标还在晃呢?
    )	
}

winform.show(); 
win.loopMessage();