#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ #_/ ◆ Window Screen Capture - KGC_ScreenCapture ◆ XP/VX ◆ #_/ ◇ Last Update: 2008/01/02 #_/ ◆ Written by TOMY #_/ ◆ Translation by Mr. Anonymous #_/ ◆ KGC Site: #_/ ◆ http://ytomy.sakura.ne.jp/ #_/ ◆ Translator's Blog: #_/ ◆ http://mraprojects.wordpress.com #_/---------------------------------------------------------------------------- #_/ Installation: Requires and is inserted below KGC_InterfaceForWin32API. #_/============================================================================ #_/ This script allows you to make screen shots. Images are saved the the root #_/ project folder. This script works for both RMVX and RMXP. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ #=============================================================================# # ★ BEGIN Customization ★ # #=============================================================================# module KGC module ScreenCapture # ◆ Screen Capture Key # Assigns the key used for manual screen capturing. # The button is disabled if set to nil. Ex: CAPTURE_BUTTON = Input::nil CAPTURE_BUTTON = Input::F8 # ◆ CTRL Key Option Toggle # This toggle allows you to require the CTRL key to be held while pressing # the Screen Capture Key (Default: F8) # true = CTRL must be held. # false = CTRL is not required. USE_CTRL = false # ◆ ALT Key Option Toggle (See above) USE_ALT = false # ◆ SHIFT Key Option Toggle (See above) USE_SHIFT = false # ◆ Screenshot Filename Format # This allows you to change the format of the image file that is saved when # a screenshot is made. # {num} = an incremental number added when saving the file. NAME_FORMAT = "Screenshot{num}.bmp" # ◆ Screen Capture Sound Effect # This allows you to change the sound effect(SE) played when a screenshot is # made. If set to nil, no sound is played. Ex: SUCCESS_SE = nil if $DEBUG # XP-Only SUCCESS_SE = RPG::AudioFile.new("056-Right02") elsif $TEST # VX-Only SUCCESS_SE = RPG::SE.new("Up", 100, 150) end end end #=============================================================================# # ★ END Customization ★ # #=============================================================================# #============================================================================== # ■ TCap #============================================================================== module TCap CP_UTF8 = 65001 # UTF-8 Unicode #-------------------------------------------------------------------------- # ● The TCap.dll version is aquired. # (Example: 1.23 → 123) #-------------------------------------------------------------------------- def self.version begin api = Win32API.new('TCap.dll', 'DllGetVersion', %w(v), 'l') ret = api.call rescue ret = -1 end return ret end #-------------------------------------------------------------------------- # ● Capture Game Screen # filename : output destination (bmp) #-------------------------------------------------------------------------- def self.capture(filename) begin hwnd = Win32API.GetHwnd if hwnd == 0 hwnd = Win32API.GetActiveWindow end if hwnd == 0 ret = -1 else tcap = Win32API.new('TCap.dll', 'CaptureA', %w(l p l l), 'l') ret = tcap.call(hwnd, filename, 1, CP_UTF8) Graphics.frame_reset end rescue ret = -1 end return ret end end #============================================================================== # ■ Input #============================================================================== if ($DEBUG || $TEST) && KGC::ScreenCapture::CAPTURE_BUTTON != nil module Input @@_capture_num = 1 CAPTURE_FILE_NAME = KGC::ScreenCapture::NAME_FORMAT.gsub(/{num}/) { "%03d" } #-------------------------------------------------------------------------- # ● Frame Update #-------------------------------------------------------------------------- unless defined?(update_KGC_ScreenCapture) class << Input alias update_KGC_ScreenCapture update end def self.update update_KGC_ScreenCapture judge_capture end end #-------------------------------------------------------------------------- # ● Capture Execution Judgement #-------------------------------------------------------------------------- def self.judge_capture if trigger?(KGC::ScreenCapture::CAPTURE_BUTTON) && (!KGC::ScreenCapture::USE_CTRL || press?(CTRL)) && (!KGC::ScreenCapture::USE_ALT || press?(ALT)) && (!KGC::ScreenCapture::USE_SHIFT || press?(SHIFT)) result = TCap.capture(sprintf(CAPTURE_FILE_NAME, @@_capture_num)) if result == 0 capture_se = KGC::ScreenCapture::SUCCESS_SE if capture_se != nil $DEBUG ? $game_system.se_play(capture_se) : capture_se.play end @@_capture_num += 1 end end end end end