Project1
标题:
调用窗口问题
[打印本页]
作者:
sblkhgm
时间:
2013-1-29 11:16
标题:
调用窗口问题
这脚本在那里改他的窗口 大小 怎么让调用的窗口贴紧游戏窗口的右侧
class String
CP_ACP = 0
CP_UTF8 = 65001
def u2s
m2w = Win32API.new("kernel32", "MultiByteToWideChar", "ilpipi", "i")
w2m = Win32API.new("kernel32", "WideCharToMultiByte", "ilpipipp", "i")
len = m2w.call(CP_UTF8, 0, self, -1, nil, 0)
buf = "\0" * (len*2)
m2w.call(CP_UTF8, 0, self, -1, buf, buf.size/2)
len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil)
ret = "\0" * len
w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil)
return ret
end
def s2u
m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
len = m2w.call(CP_ACP, 0, self, -1, nil, 0);
buf = "\0" * (len*2)
m2w.call(CP_ACP, 0, self, -1, buf, buf.size/2);
len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
ret = "\0" * len
w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);
return ret
end
def s2u!
self[0,length] = s2u
end
def u2s!
self[0, length] = u2s
end
end
module Debug
REPLACE = true
AllocConsole = Win32API.new("kernel32", "AllocConsole", "v", "i")
GetStdHandle = Win32API.new("kernel32", "GetStdHandle", "l", "l")
ReadConsole = Win32API.new("kernel32", "ReadConsole","lplpp", "i")
WriteConsole = Win32API.new("kernel32", "WriteConsole", "lplpp", "i")
FreeConsole = Win32API.new("kernel32", "FreeConsole", "v", "i")
module_function
def init
AllocConsole.call
@h = GetStdHandle.call -11
end
def free
FreeConsole.call
@h = nil
end
def validcheck
raise "必须先调用Debug.init进行初始化!" if @h.nil?
end
def print(*args)
validcheck; str = ""
args.each{|obj| str += obj.is_a?(String) ? obj : obj.inspect}; str.u2s!
WriteConsole.call @h, str, str.length, nil, nil
end
def println
validcheck; WriteConsole.call @h, "\n", 1, nil, nil
end
def p(*args)
validcheck
str = ""; args.each{|obj| str += obj.inspect + "\n"}; str.u2s!
WriteConsole.call @h, str, str.length, nil, nil
end
def gets
validcheck
str = "/0"*256
len = [0].pack("L")
begin
ReadConsole.call GetStdHandle.call(-10),str,str.length,len,nil
nil
rescue Hangup
# 10s 的容错
p $!, str.delete("\0"), len.unpack("L")[0]
end
Debug.println
return str.s2u!.delete("\r\n").delete("/0").delete("\000")
end
class << self
private :validcheck
alias puts print
end
if REPLACE
alias origin_print print
alias origin_p p
self.init if @h.nil?
end
end
module Kernel
def print(*args)
Debug.print *args
end
def p(*args)
Debug.p *args
end
def gets
Debug.gets
end
alias ori_exit exit
def exit(*args)
Debug.free
ori_exit(*args)
end
end
复制代码
作者:
Chen。
时间:
2013-1-29 13:56
说清楚点
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1