#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ #_/ ◆ Win32API Interface - KGC_InterfaceForWin32API ◆ XP/VX ◆ #_/ ◇ Last Update: 2007/11/26 #_/ ◆ Written by TOMY #_/ ◆ Translation by Mr. Anonymous #_/ ◆ KGC Site: #_/ ◆ http://ytomy.sakura.ne.jp/ #_/ ◆ Translator's Blog: #_/ ◆ http://mraprojects.wordpress.com #_/----------------------------------------------------------------------------- #_/ This script allows RMVX or RMXP to aquire the Win32API interface. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ class Win32API STRING_BUF_SIZE = 255 #-------------------------------------------------------------------------- # ● Read INI File # section : Section name # key : Key # default : default value when a key doesn't exist # inifile : Passing of read INI file #-------------------------------------------------------------------------- def self.GetPrivateProfileString(section, key, default, inifile) get_ini = Win32API.new( 'kernel32.dll', 'GetPrivateProfileStringA', %w(p p p p l p), 'l') buf = "\0" * (STRING_BUF_SIZE + 1) get_ini.call(section, key, default, buf, STRING_BUF_SIZE, inifile) return buf.delete!("\0") end #-------------------------------------------------------------------------- # ● Aquire Window # window_class : Window class name # window_title : Title of window #-------------------------------------------------------------------------- def self.FindWindow(window_class, window_title) find_window = Win32API.new('user32.dll', 'FindWindowA', %w(p p), 'l') return find_window.call(window_class, window_title) end #-------------------------------------------------------------------------- # ● Aquire Active Window #-------------------------------------------------------------------------- def self.GetActiveWindow active_window = Win32API.new('user32.dll', 'GetActiveWindow', %w(v), 'l') return active_window.call end #-------------------------------------------------------------------------- # ● Aquire Game Window #-------------------------------------------------------------------------- def self.GetHwnd name = GetPrivateProfileString("Game", "Title", "", "./Game.ini") return FindWindow("RGSS Player", name) end end