赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 5 |
经验 | 13891 |
最后登录 | 2021-4-14 |
在线时间 | 329 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 524
- 在线时间
- 329 小时
- 注册时间
- 2013-5-16
- 帖子
- 740
|
本帖最后由 亿万星辰 于 2013-6-7 13:11 编辑
亿万星辰 发表于 2013-6-6 12:51
夏娜的输入法是哪个?
我截图只能截出个记事本来~
get_hWnd方法是获取当前游戏窗口句柄的方法 - =begin
- 脚本:【完美输入法修正】
-
- 功能:输入法。
-
- 说明: 直接用Type_Field创建输入域即可进行输入,在此可根据Type_Field域对象
-
- 的活动标记active来自定义刷新等,在Type_Field中需要自己处理特殊按键
-
- 的处理方法。具体不明白之处请参考范例工程。
- 作者:灼眼的夏娜
-
- 补充: 至于以前那个版本也许很多人都注意到那个烦人的问题了吧,按Enter和Tab那
-
- 些会出现不爽的声音,这个版本解决了那个问题,并简化添加了Type_Field类
-
- 来方便创建输入域。
- =end
- #==============================================================================
- # ■ RInput
- #------------------------------------------------------------------------------
- # 全键盘处理的模块。
- #==============================================================================
- module RInput
- #--------------------------------------------------------------------------
- # ● 常量定义
- #--------------------------------------------------------------------------
- ENTER = 0x0D
- SPACE = 0x20
- UP = 0x26
- DOWN = 0x28
- LEFT = 0x25
- RIGHT = 0x27
-
- LCTRL = 0xA2
- LALT = 0xA4
- TAB = 0x09
-
- F1 = 0x70
- ESCAPE = 0x1B
- Key_0 = 0x30 # 0 key
- Key_1 = 0x31 # 1 key
- Key_2 = 0x32 # 2 key
- Key_3 = 0x33 # 3 key
- Key_4 = 0x34 # 4 key
- Key_5 = 0x35 # 5 key
- Key_6 = 0x36 # 6 key
- Key_7 = 0x37 # 7 key
- Key_8 = 0x38 # 8 key
- Key_9 = 0x39 # 9 key
- #--------------------------------------------------------------------------
- # ● 临时Hash
- #--------------------------------------------------------------------------
- @R_Key_Hash = {}
- @R_Key_Repeat = {}
-
- #--------------------------------------------------------------------------
- # ● 唯一API
- #--------------------------------------------------------------------------
- GetKeyState = Win32API.new("user32","GetAsyncKeyState",['I'],'I')
-
- #--------------------------------------------------------------------------
- # ● 单键按下
- #--------------------------------------------------------------------------
- def self.press?(rkey)
- return GetKeyState.call(rkey) != 0
- end
- #--------------------------------------------------------------------------
- # ● 单键重复按下
- #--------------------------------------------------------------------------
- def self.repeat?(rkey)
- result = GetKeyState.call(rkey)
- if result != 0
- if @R_Key_Repeat[rkey].nil?
- @R_Key_Repeat[rkey] = 0
- return true
- end
- @R_Key_Repeat[rkey] += 1
- else
- @R_Key_Repeat[rkey] = nil
- @R_Key_Hash[rkey] = 0
- end
- #当连续按3下同一键时候返回=0
- if !@R_Key_Repeat[rkey].nil? and @R_Key_Repeat[rkey] > 3 # 4乃准确数字
- @R_Key_Repeat[rkey] = 0
- return true
- else
- return false
- end
- end
-
- #--------------------------------------------------------------------------
- # ● 单键处理
- #--------------------------------------------------------------------------
- def self.trigger?(rkey)
- result = GetKeyState.call(rkey)
- if @R_Key_Hash[rkey] == 1 and result != 0
- return false
- end
- if result != 0
- @R_Key_Hash[rkey] = 1
- return true
- else
- @R_Key_Hash[rkey] = 0
- return false
- end
- end
- end
- #==============================================================================
- # ■ EasyConv
- #------------------------------------------------------------------------------
- # 转码模块。
- #==============================================================================
- module EasyConv
- #--------------------------------------------------------------------------
- # ● 常量定义
- #--------------------------------------------------------------------------
- CP_ACP = 0
- CP_UTF8 = 65001
- #--------------------------------------------------------------------------
- # ● 模块函数
- #--------------------------------------------------------------------------
- module_function
-
- #--------------------------------------------------------------------------
- # ● 转码
- #--------------------------------------------------------------------------
- def s2u(text)
- m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
- w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
- len = m2w.call(CP_ACP, 0, text, -1, nil, 0)
- buf = "\0" * (len*2)
- m2w.call(CP_ACP, 0, text, -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)
- ret[-1] = ""
-
- return ret
- end
- #--------------------------------------------------------------------------
- # ● 转码
- #--------------------------------------------------------------------------
- def u2s(text)
-
- m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
- w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
- len = m2w.call(CP_UTF8, 0, text, -1, nil, 0)
- buf = "\0" * (len*2)
- m2w.call(CP_UTF8, 0, text, -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
- end
- #==============================================================================
- # ■ TypeAPI
- #------------------------------------------------------------------------------
- # 输入法相关API模块。
- #==============================================================================
- module TypeAPI
- #--------------------------------------------------------------------------
- # ● API定义
- #--------------------------------------------------------------------------
- GPPS = Win32API.new("kernel32","GetPrivateProfileString",'pppplp','l')
- FindWindow = Win32API.new("user32", "FindWindow", 'pp', 'i')
- CreateWindow = Win32API.new("NetGame","CreatWnd",'l','l')
- SetHK = Win32API.new("NetGame","SetHK",'v','v')
- GetText = Win32API.new("NetGame","GetWndText",'l','p')
- SetFocus = Win32API.new("user32","SetFocus",'l','l')
- IfBack = Win32API.new("NetGame","If_Back",'v','i')
- StartType = Win32API.new("NetGame","StartType",'v','v')
- EndType = Win32API.new("NetGame","EndType",'v','v')
- GetKeyInfos = Win32API.new("NetGame","GetKeyInfo",'v','i')
- #--------------------------------------------------------------------------
- # ● 模块函数
- #--------------------------------------------------------------------------
- module_function
- #=begin
- #--------------------------------------------------------------------------
- # ● 获取参数
- #--------------------------------------------------------------------------
- def getParam
- val = "\0" * 256
- GPPS.call("Game","Title","",val,256,"./Game.ini")
- val.delete!("\0")
- return val
- end
-
- #--------------------------------------------------------------------------
- # ● 获取窗口
- #--------------------------------------------------------------------------
- def findWindow
- return FindWindow.call("RGSS Player",self.getParam)
- return FindWindow.call("",self.getParam)
- end
- #=end
- =begin
- #--------------------------------------------------------------------------
- # ● 获取参数
- #--------------------------------------------------------------------------
- def getParam
- val = 0.chr * 256
- GPPS.call("Game","Title","",val,256,"./Game.ini")
- val.delete!("\0")
- return val
- end
- #--------------------------------------------------------------------------
- # ● 获取窗口
- #--------------------------------------------------------------------------
- def findWindow
- Win32API.new("user32","FindWindow","pp","i").call("RGSS Player",self.getParam)
- end
- =end
- #--------------------------------------------------------------------------
- # ● 创建窗口
- #--------------------------------------------------------------------------
- def createWindow(hwnd)
- return CreateWindow.call(hwnd)
- end
-
- #--------------------------------------------------------------------------
- # ● 设置HK
- #--------------------------------------------------------------------------
- def setHK
- SetHK.call
- end
-
- #--------------------------------------------------------------------------
- # ● 获取文字
- #--------------------------------------------------------------------------
- def getText
- return EasyConv.s2u(GetText.call(@subhwnd))
- end
-
- #--------------------------------------------------------------------------
- # ● 设置焦点
- #--------------------------------------------------------------------------
- def setFocus
- SetFocus.call(@subhwnd)
- end
-
- #--------------------------------------------------------------------------
- # ● 转换焦点
- #--------------------------------------------------------------------------
- def lostFocus
- SetFocus.call(@hwnd)
- end
-
- #--------------------------------------------------------------------------
- # ● 退格判定
- #--------------------------------------------------------------------------
- def ifBack
- return IfBack.call
- end
-
- #--------------------------------------------------------------------------
- # ● 开始输入
- #--------------------------------------------------------------------------
- def startType
- StartType.call
- end
-
- #--------------------------------------------------------------------------
- # ● 结束输入
- #--------------------------------------------------------------------------
- def endType
- EndType.call
- end
- #--------------------------------------------------------------------------
- # ● 输入中特殊按键处理
- #--------------------------------------------------------------------------
- def getKeyInfos
- return GetKeyInfos.call
- end
-
- #--------------------------------------------------------------------------
- # ● 获取句柄
- #--------------------------------------------------------------------------
- @hwnd = self.findWindow
- @subhwnd = self.createWindow(@hwnd)
- #--------------------------------------------------------------------------
- # ● 设置HK应用
- #--------------------------------------------------------------------------
- self.setHK
-
- end
- #==============================================================================
复制代码 |
|