赞 | 5 |
VIP | 1 |
好人卡 | 2 |
积分 | 4 |
经验 | 20430 |
最后登录 | 2018-5-11 |
在线时间 | 238 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 381
- 在线时间
- 238 小时
- 注册时间
- 2013-8-20
- 帖子
- 496
|
3楼
楼主 |
发表于 2014-4-22 18:58:48
|
只看该作者
- #==============================================================================
- # [XP/VX] 精确获取窗口句柄 by 紫苏
- #==============================================================================
- # ■ Kernel
- #==============================================================================
- module Kernel
- #--------------------------------------------------------------------------
- # ● 需要的 Windows API 函数
- #--------------------------------------------------------------------------
- GetWindowThreadProcessId = Win32API.new("user32", "GetWindowThreadProcessId", "LP", "L")
- GetWindow = Win32API.new("user32", "GetWindow", "LL", "L")
- GetClassName = Win32API.new("user32", "GetClassName", "LPL", "L")
- GetCurrentThreadId = Win32API.new("kernel32", "GetCurrentThreadId", "V", "L")
- GetForegroundWindow = Win32API.new("user32", "GetForegroundWindow", "V", "L")
- #--------------------------------------------------------------------------
- # ● 获取窗口句柄
- #--------------------------------------------------------------------------
- def get_hwnd
- # 获取调用线程(RM 的主线程)的进程标识
- threadID = GetCurrentThreadId.call
- # 获取 Z 次序中最靠前的窗口
- hWnd = GetWindow.call(GetForegroundWindow.call, 0)
- # 枚举所有窗口
- while hWnd != 0
- # 如果创建该窗口的线程标识匹配本线程标识
- if threadID == GetWindowThreadProcessId.call(hWnd, 0)
- # 分配一个 11 个字节的缓冲区
- className = " " * 11
- # 获取该窗口的类名
- GetClassName.call(hWnd, className, 12)
- # 如果匹配 RGSS Player 则跳出循环
- break if className == "RGSS Player"
- end
- # 获取下一个窗口
- hWnd = GetWindow.call(hWnd, 2)
- end
- return hWnd
- end
- end
- module Kernel
- GetActiveWindow = Win32API.new("user32", "GetActiveWindow", "V", "L")
- def shit?
- #return if Graphics.frame_count % 10 != 0
- # 获取调用线程(RM 的主线程)的进程标识
- threadID = GetCurrentThreadId.call
- # 获取 Z 次序中最靠前的窗口
- hWnd = GetActiveWindow.call#GetForegroundWindow.call
- return true if threadID == GetWindowThreadProcessId.call(hWnd, 0)
- return false
- # 枚举所有窗口
- #while hWnd != 0
- # 如果创建该窗口的线程标识匹配本线程标识
- #if threadID == GetWindowThreadProcessId.call(hWnd, 0)
- # 分配一个 11 个字节的缓冲区
- className = " " * 11
- # 获取该窗口的类名
- GetClassName.call(hWnd, className, 12)
- # 如果匹配 RGSS Player 则跳出循环
- $windowInfo.newText += (className + "")
- #break if className == "RGSS Player"
- #end
- # 获取下一个窗口
- #hWnd = GetWindow.call(hWnd, 2)
- #end
- #return hWnd
- end
- end
- class << Input
- alias shitmyoh trigger? unless $@
- def Input.trigger?(input)
- return false if !shit?#GetWindow.call(GetForegroundWindow.call, 0) != 0 &&
- shitmyoh(input)
- end
-
- end
复制代码 难道指的是这个{:7_297:}
可是好像没有效果呢{:7_298:}
@铃仙·优昙华院·因幡 |
|