设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2411|回复: 3
打印 上一主题 下一主题

[转载发布] 发个战斗前截取当前地图当背景的脚本

[复制链接]

Lv1.梦旅人

梦石
0
星屑
76
在线时间
1379 小时
注册时间
2012-7-5
帖子
1698

开拓者

1
发表于 2013-12-13 12:55:10 | 显示全部楼层
本帖最后由 kuerlulu 于 2013-12-13 12:56 编辑

截图脚本我以前玩过【雾。。
夏娜大大加了个防止多个RM一起运行导致获取窗口句柄出错的方法。【这句和上面一句没有必然联系
  1. #==============================================================================
  2. # ■ Kernel
  3. #------------------------------------------------------------------------------
  4. #  该模块中定义了可供所有类使用的方法。Object 类中包含了该模块。
  5. #==============================================================================
  6. module Kernel
  7.   #--------------------------------------------------------------------------
  8.   # ● 需要的 Windows API 函数
  9.   #--------------------------------------------------------------------------
  10.   GetWindowThreadProcessId = Win32API.new("user32", "GetWindowThreadProcessId", "LP", "L")
  11.   GetWindow = Win32API.new("user32", "GetWindow", "LL", "L")
  12.   GetClassName = Win32API.new("user32", "GetClassName", "LPL", "L")
  13.   GetCurrentThreadId = Win32API.new("kernel32", "GetCurrentThreadId", "V", "L")
  14.   GetForegroundWindow = Win32API.new("user32", "GetForegroundWindow", "V", "L")
  15.   #--------------------------------------------------------------------------
  16.   # ● 获取窗口句柄
  17.   #--------------------------------------------------------------------------
  18.   def get_hWnd
  19.     # 获取调用线程(RM 的主线程)的进程标识
  20.     threadID = GetCurrentThreadId.call
  21.     # 获取 Z 次序中最靠前的窗口
  22.     hWnd = GetWindow.call(GetForegroundWindow.call, 0)
  23.     # 枚举所有窗口
  24.     while hWnd != 0
  25.       # 如果创建该窗口的线程标识匹配本线程标识
  26.       if threadID == GetWindowThreadProcessId.call(hWnd, 0)
  27.         # 分配一个 11 个字节的缓冲区
  28.         className = " " * 11
  29.         # 获取该窗口的类名
  30.         GetClassName.call(hWnd, className, 12)
  31.         # 如果匹配 RGSS Player 则跳出循环
  32.         break if className == "RGSS Player"
  33.       end
  34.       # 获取下一个窗口
  35.       hWnd = GetWindow.call(hWnd, 2)
  36.     end
  37.     return hWnd
  38.   end
  39. end
  40. #===============================================================================
  41. #===============================================================================
  42. # ■设置存放截图文件夹
  43. DIR = "Screenshot"
  44. Dir.mkdir("./#{DIR}") unless FileTest.exist?(DIR + "/")
  45.   # 主模块 Screen API ★方法:Screen::shot★
  46. module Screen
  47.   @i = 1 # 又要玩迭代了
  48.   @screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p l l), ''
  49.   @readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l'
  50.   @findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
  51.   module_function
  52.   def shot(file = "shot", typ = 1) # Screen::shot("save", 1)
  53.     if typ == 0
  54.       typname = ".bmp"
  55.     elsif typ == 1
  56.       typname = ".jpg"
  57.     elsif typ == 2
  58.       typname = ".png"
  59.     end
  60.     dir = DIR + "/"
  61.     @i += 1 while FileTest.exist?(dir + file.to_s  + @i.to_s + typname.to_s)
  62.     file_name = dir + file.to_s  + @i.to_s + typname.to_s # 生成带路径的文件名
  63.     @screen.call(0,0,640,480, file_name, get_hWnd, typ) # call出截图
  64.   end
  65. #  def handel
  66. #    game_name = "\0" * 256
  67. #    @readini.call('Game','Title','',game_name,255,".\\Game.ini")
  68. #    game_name.delete!("\0")
  69. #    return @findwindow.call('RGSS Player',game_name)
  70. #  end
  71. end
复制代码

  -fk: -azogi:
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-4 19:52

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表