#==============================================================================
# ■ Kernel
#------------------------------------------------------------------------------
# 该模块中定义了可供所有类使用的方法。Object 类中包含了该模块。
#==============================================================================
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
#===============================================================================
# 目标:调教screenshot.dll
# 说明:hy扒自截图存档脚本
#===============================================================================
# ■来设置存放截图文件夹吧(/代替\\哦~)■
DIR = "Screenshot"
# ■创建文件夹(内部方法)■# system("md Screenshot")方法一样可行,只是会弹cmd黑框
Dir.mkdir("./#{DIR}") unless FileTest.exist?(DIR + "/")
# 主模块 Screen API ★方法:Screen::shot★
module Screen
@i = 1 # 又要玩迭代了
@screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p l l), ''
@readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l'
@findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
module_function
def shot(file = "shot", typ = 1) # Screen::shot("Save", 1) 拿到截图存档脚本
if typ == 0
typname = ".bmp"
elsif typ == 1
typname = ".jpg"
elsif typ == 2
typname = ".png"
end
dir = DIR + "/"
# ★ 下面这行是重点 ★
@i += 1 while FileTest.exist?(dir + file.to_s + @i.to_s + typname.to_s)
file_name = dir + file.to_s + @i.to_s + typname.to_s # 生成带路径的文件名
@screen.call(0,0,640,480, file_name, get_hWnd, typ) # call出截图
end
# def handel
# game_name = "\0" * 256
# @readini.call('Game','Title','',game_name,255,".\\Game.ini")
# game_name.delete!("\0")
# return @findwindow.call('RGSS Player',game_name)
# end
def play
@i = 0
@x = 1
dir = DIR + "/"
file = "CG"
typname = ".jpg"
@file_name = dir + file.to_s + @i.to_s + typname.to_s
@x += 1 while FileTest.exist?(dir + file.to_s + @x.to_s + typname.to_s)
# ================== 赋值完毕 ===================
# 参数说明:
# Graphics.transition(10) 用10帧完成画面渐变
# ============= 淡入真的只需要两句 ==============
[url=home.php?mod=space&uid=114926]@sprite[/url] = Sprite.new
Graphics.freeze # 第一句
@sprite.bitmap = Bitmap.new(@file_name)
Graphics.transition(10) # 第二句
loop do
Graphics.freeze
# 赋值一次之后不会重复更新另一个值
@file_name = dir + file.to_s + @i.to_s + typname.to_s
@sprite.bitmap = Bitmap.new(@file_name)
Graphics.update
@i += 1
if @i == @x
break
end
Graphics.transition(20) # 帧
end
@sprite.bitmap.dispose
@sprite.dispose
Graphics.transition(40)
end
end