重置RM窗口过程:将RM的窗口过程加多了一层.
且可选择是否将原过程打断..
这样可以做很多东西..
例如屏蔽F1 或者 屏蔽全屏..
这些在默认都是通过消息来处理的``
或者手动发送一个全屏的消息..
不需要模拟键盘..
还有个比较好的地方.
就是鼠标可以脱离API..
MOUSEMOVE 消息附带坐标位置``呵呵..而且这东西是由系统回调的...
这样就不必每帧都GetCursorPos了。
拼命的晃动鼠标都没有掉帧的现象.
其实只要截取到了消息,自己接下来干啥都可以的了。
完一下以前的想法,呵呵[code]# API申明module WM_API # 寻找窗口 FindWindow = Win32API.new("user32", "FindWindow", "pp", "l") # 重置窗口过程 ReSetProc = Win32API.new("WndProc.dll", "ReSetProc", "l", "l") # 设置RGSSEval的库 SetDLL = Win32API.new("WndProc.dll", "SetDLL", "p", "v") # 旧的过程 OldProc = Win32API.new("WndProc.dll", "OldProc", "llll", "l") # 设置打断 SetBreak = Win32API.new("WndProc.dll", "SetBreak", "", "v") # 发送消息 SendMessage = Win32API.new("user32", "SendMessage", "llll", "l") # 设置鼠标显示 ShowCursor = Win32API.new("user32", "ShowCursor", "l", "l") # 设置鼠标位置 SetMousePos = Win32API.new("WndProc.dll", "SetMousePos", "lll", "v") # 读取INI GetPrivateProfileString = Win32API.new("kernel32", "GetPrivateProfileString", "pppplp", "l")end# 参数表module WM_MSG # 关闭 WM_CLOSE = 0x0010 # 鼠标移动 WM_MOUSEMOVE = 0x0200 # 鼠标按键 WM_LBUTTONDOWN = 0x0201 WM_LBUTTONUP = 0x0202 WM_LBUTTONDBLCLK = 0x0203 WM_RBUTTONDOWN = 0x0204 WM_RBUTTONUP = 0x0205 WM_RBUTTONDBLCLK = 0x0206 WM_MBUTTONDOWN = 0x0207 WM_MBUTTONUP = 0x0208 WM_MBUTTONDBLCLK = 0x0209 WM_MOUSEWHEEL = 0x020a # 全屏 or F2 WM_RM_FULL = 0x0111 # F1按下 or 小红叉 WM_RM_HELP = 0x0112end# 处理过程函数的模块module WndProc # API include WM_API # 消息常数 include WM_MSG # 消息 #@@msg = [] # 函数 module_function # 开始 def init ShowCursor.call(0) self.set_dll self.re_set_proc end # 窗口句柄 def hWnd buffer = "\000"*256 GetPrivateProfileString.call("Game", "Title", "", buffer, 256, "./Game.ini") buffer.delete!("\000") hWnd = FindWindow.call("RGSS Player", buffer) end # 设置RGSSEval库 def set_dll(libname="RGSS102J.dll") SetDLL.call(libname) end # 重置回调函数 def re_set_proc ReSetProc.call(hWnd) end # 新的回调 def proc(hWnd, message, wParam, lParam) #@@msg > 16) & 0xFFFF # 设置鼠标位置 Input.mouse.set_pos(x, y) when WM_LBUTTONDOWN # 左按下 when WM_LBUTTONUP # 左松开 when WM_LBUTTONDBLCLK # 左双击 when WM_RBUTTONDOWN # 右按下 when WM_RBUTTONUP # 右松开 when WM_RBUTTONDBLCLK # 右双击 when WM_MBUTTONDOWN # 滚轮按下 when WM_MBUTTONUP # 滚轮松开 when WM_MBUTTONDBLCLK # 滚轮双击 when WM_MOUSEWHEEL # 滚轮转动 if(wParam > 0) # 向上滚 else # 向下滚 end when WM_RM_HELP # F1, 关闭也是这个消息.不过参数不同.区分即可 if wParam == 40003 && lParam == 65536 break_rm(); end when WM_RM_FULL # Alt + Enter or F2 按下,同样可以屏蔽 case wParam # Alt + Enter 按下,同样可以屏蔽 when 105538 # Alt + Enter # 加这个判断是为了,后面添加一个手动全屏幕的函数 if lParam == 0 break_rm(); end # F2 按下,是可以打断的 when 105540 # F2 break_rm(); end end end # 全屏 def full_screen SendMessage.call(self.hWnd, WM_RM_FULL, 105538, 1) end # 打断RM的过程 def break_rm SetBreak.call endend# 简易鼠标class Mouse include WndProc attr_reader :x attr_reader :y def initialize @x = 0 @y = 0 @sprite = Sprite.new() @sprite.bitmap = RPG::Cache.icon("001-Weapon01") @sprite.z = 999999 @sprite.visible = false set_visible(true) end def set_visible(bool) @sprite.visible = bool end def set_pos(x, y) @x = x @y = y @sprite.x = x @sprite.y = y endendclass