Project1
标题:
【VX\XP】高仿VA控制台
[打印本页]
作者:
张咚咚
时间:
2017-9-11 11:46
标题:
【VX\XP】高仿VA控制台
本帖最后由 张咚咚 于 2018-11-20 17:44 编辑
#==============================================================================
# ■ Console
# By QQEat
#------------------------------------------------------------------------------
# 高仿VA控制台。
# puts:控制台打印
#==============================================================================
if $TEST or $DEBUG
Win32API.new("kernel32", "AllocConsole", "v", "i").call #创建
#~ Win32API.new("kernel32", "FreeConsole", "v", "i").call #释放
Win32API.new("kernel32", "SetConsoleTitle", "p", "i").call("RGSS Console") #setTitle
GetStdHandle = Win32API.new("kernel32", "GetStdHandle", "i", "i") #I/O_hWnd
WriteConsole = Win32API.new("kernel32", "WriteConsole", "ipiii", "i") #WriteConsole
GetStringLength = Win32API.new("kernel32", "lstrlenA", "p", "i") #getStringLength
def puts(*args)
str = ""
args.each{|a| str << (a.is_a?(String) ? "\"" << a.to_s << "\"" : a.inspect) << "\n" }
#处理编码
m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
len = m2w.call(0xFDE9,0,str,-1,nil,0)
buf = "\0" * (len*2)
m2w.call(0xFDE9,0,str,-1,buf,buf.size/2)
len = w2m.call(0,0,buf,-1,nil,0,nil,nil)
ret = "\0" * len
w2m.call(0,0,buf,-1,ret,ret.size,nil,nil)
str = ret.delete!("\0")
WriteConsole.call(GetStdHandle.call(-12), str, GetStringLength.call(str), 0, 0)
end
else
def puts(*args);end
end
HWnd = Win32API.new('user32','FindWindowEx','llpp','i')
Win32API.new('user32','SetForegroundWindow','i','i').call(HWnd.call(0, 0, 'RGSS Player', 0)) if $TEST or $DEBUG #获取焦点置前台
复制代码
作者:
guoxiaomi
时间:
2017-9-18 00:08
GetStringLength = Win32API.new("kernel32", "lstrlenA", "p", "i") #getStringLength
这个会不会因为输出中间含有 "\0" 的字符而提前终止?
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1