console窗口禁止关闭
By
admin
at 2017-12-07 • 1人收藏 • 1752人看过
import console; import win; console.open(); console.setTitle("显示日志") var hwnd = console.getWindow(); var hmenu = ::User32.GetSystemMenu(hwnd,false); ::User32.RemoveMenu(hmenu,0xF060/*_SC_CLOSE*/,0); win.modifyStyleEx(hwnd,0x40000/*_WS_EX_APPWINDOW*/,0x80/*_WS_EX_TOOLWINDOW*/); console.pause(true);
更新:
如果需要设置console控制台的位置,
import console; console.box(,,60,10,31,"请输入文本:" ) console.pause(true);
如果这个设置窗口的位置, 那么
import console var hwnd = console.getWindow(); win.setPos(hwnd,1,1); console.open()
拦截控制台关闭信息
import win.ui; /*DSG{{*/ var winform = win.form(text="aardio form";right=759;bottom=469) winform.add() /*}}*/ import console console.open() //处理函数 func = function(a) { if( a==2/*_CTRL_CLOSE_EVENT*/ ){ console.log("确定要退出吗") sleep(2000); return true; } } //转换为静态api函数约定 func_c = raw.tostdcall( func,"int(int)" ); //挂接 var ret = ::Kernel32.SetConsoleCtrlHandler(func_c,true); console.log("执行结果",ret) winform.show() win.loopMessage();
发现jacen大人已经封装好了上面的那个函数, 可以直接用''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
console.setCtrlHandlerThread( function(ctrlType){ import console; console.log("确定要退出吗"); sleep(2000); return true; })
登录后方可回帖