赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 12421 |
最后登录 | 2016-8-14 |
在线时间 | 322 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 322 小时
- 注册时间
- 2011-6-24
- 帖子
- 274
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
这脚本在那里改他的窗口 大小 怎么让调用的窗口贴紧游戏窗口的右侧- 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
复制代码 |
|