module Kernel
Console = Win32API.new('kernel32', 'AllocConsole', 'v', 'v').call
Conout = File.open("CONOUT$", "w")
def p(str)
Conout.write str
Conout.write "\n"
Conout.flush
end
#显示控制台
def show_console
_console_switch
end
#隐藏控制台
def hide_console
_console_switch(false)
end
#
def _console_switch(show = true)
Win32API.new('user32', 'ShowWindow', 'll', 'l').call(
Win32API.new('kernel32', 'GetConsoleWindow', 'v', 'l').call, show ? 5 : 0
)
end
end
module Kernel
Console = Win32API.new('kernel32', 'AllocConsole', 'v', 'v').call
Conout = File.open("CONOUT$", "w")
def p(str)
Conout.write str
Conout.write "\n"
Conout.flush
end
#显示控制台
def show_console
_console_switch
end
#隐藏控制台
def hide_console
_console_switch(false)
end
#
def _console_switch(show = true)
Win32API.new('user32', 'ShowWindow', 'll', 'l').call(
Win32API.new('kernel32', 'GetConsoleWindow', 'v', 'l').call, show ? 5 : 0
)
end
end