#================================================================
#BEGIN CLASS
#================================================================
#Script made by Squall [email protected]
#================================================================
begin
class Win32API
#==============================================================
#CONSTANTS
#==============================================================
SCREEN_WIDTH = 320
SCREEN_HEIGHT = 240
GAME_INI_FILE = ".\\Game.ini" # define "Game.ini" file
HWND_TOPMOST = 0 # window always active
HWND_TOP = 0 # window active when used only
SWP_NOMOVE = 0 # window pos and sizes can be changed
#==============================================================
#Win32API.GetPrivateProfileString
#==============================================================
#Checks your game's title in Game.ini
def Win32API.GetPrivateProfileString(section, key)
val = "\0"*256
gps = Win32API.new('kernel32', 'GetPrivateProfileString',%w(p p p p l p), 'l')
gps.call(section, key, "", val, 256, GAME_INI_FILE)
val.delete!("\0")
return val
end
#==============================================================
#Win32API.FindWindow
#==============================================================
#Finds the RGSS Window
def Win32API.FindWindow(class_name, title)
fw = Win32API.new('user32', 'FindWindow', %(p, p), 'i')
hWnd = fw.call(class_name, title)
return hWnd
end
#==============================================================
#Win32API.SetWindowPos
#==============================================================
#Changes Window position and size
def Win32API.SetWindowPos(w, h)
title = Win32API.GetPrivateProfileString("Game", "Title")
hWnd = Win32API.FindWindow("RGSS Player", title)
swp = Win32API.new('user32', 'SetWindowPos', %(l, l, i, i, i, i, i), 'i')
win = swp.call(hWnd, HWND_TOP, 0, 0, w + 6, h + 26, 0)
#the line below makes the window on top of all others
win = swp.call(hWnd, HWND_TOPMOST, 0, 0, w + 6, h + 26, SWP_NOMOVE)
return win
end
#==============================================================
#Win32API.client_size
#==============================================================
#Checks the Window's width and height
def Win32API.client_size
title = Win32API.GetPrivateProfileString("Game", "Title")
hWnd = Win32API.FindWindow("RGSS Player", title)
rect = [0, 0, 0, 0].pack('l4')
Win32API.new('user32', 'GetClientRect', %w(l p), 'i').call(hWnd, rect)
width, height = rect.unpack('l4')[2..3]
return width, height
end
#================================================================
#END CLASS
#================================================================
end
#==============================================================
#Win32API.client_size
#==============================================================
#The width and height variables set the screen size.
win = Win32API.SetWindowPos(320, 246)
if(win == 0)
p "Size change has failed!"
end
end