this is how you do it:
open url in xp demo that being said you will have issues play testing this unless you are running as admin due to its use of registry key.
edit here is code in case others dont have xp because i dont plan on helping you t/s this.
aleworks
[rgss]#=============================================================================
# *** Aleworks Library(ALibrary)
#=============================================================================
# Created by Aleworks
# Version: 1.01
# Last Modification: 11/09/2007 (day/month/year)
#=============================================================================
#==== Description ====
# This script is a library, of tools and methods specialy designed for others
# Aleworks scripts, however you are free to use it, as long as you give credit.
#=============================================================================
#==== Credits ====
# * Ruby 1.8
# - For the Win32::Registry class, that was the base for Aleworks::Registry
# * Cybersam
# - For some APIs functions for getting mouse position
# * Nishikawa, Yasuhiro
# - For some APIs for the Aleworks::Clipboard
#=============================================================================
#==== Version History ====
# * Version 1.01
# - Lots of fixes
# - New methods:
# - Aleworks: check_hang_up; translate_string; get_window_rect
# - API: get_client_rect
# - String: trans_undrawable_chr; insert
# - Nil: clone
# - Array: insert
# - Bitmap: initialize; bmp_dump
# - New constants:
# - Aleworks: ASCII_TABLE; TRANSLATE_TABLE
#=============================================================================
#==== Classes & Methods ====
# ** Module Aleworks
# * Constants:
# - Active_Window
# Id of the Game window.
# - Current_Process_Id
# Id of the Game process.
# - Keyboard_Layout
# Id of the used keyboard layout.
# - ASCII_TABLE
# Hash containing the characters corresponding to each of the 255 ascii
# codification.
# - TRANSLATE_TABLE
# Hash containing the characters corresponding to the back references.
# * Methods:
# - Aleworks.get_keyboard_layout_name
# Returns an array containing the name of the keyboard layout, and its
# abbreviation.
# - Aleworks.get_current_desktop_path
# Returns the path of the user desktop folder.
# - Aleworks.get_current_userdocuments_path
# Returns the path of the user personal documents folder.
# - Aleworks.get_common_desktop_path
# Returns the path of the common desktop folder.
# - Aleworks.get_common_usersdocuments_path
# Returns the path of the common personal documents folder.
# - Aleworks.get_fonts_folder_path
# Returns the path of the common users personal documents folder.
# - Aleworks.get_fonts_names
# Returns all usable fonts names.
# - Aleworks.get_mouse_swap_buttons_flag
# Returns 1 if the mouse button are inverted, 0 instead.
# - Aleworks.get_mouse_position
# Returns an array with the coordinates of the mouse cursor.
# - Aleworks.get_mouse_window_position([hwnd])
# Returns an array with the coordinates of the mouse cursor, in the given
# hwnd. If hwnd is not given, it will be used the rgss player.
# - Aleworks.check_hang_up(time)
# Updates the module Graphics for prevention of a System Stack Error.
# - Aleworks.translate_string(string)
# Returns the translation of back reference characters to normal
# characters.
# - Aleworks.get_window_rect([hwnd])
# Returns an array containing the rect of the given window. If hwnd is not
# given, it will be the game window.
# Note: The rect includes the borders and title bar of the window.
# ** Module Aleworks::API
# * Methods:
# - API.get_rtp_path([rtp])
# Returns the folder path of the RTP number 'rtp'-1. If 'rtp' is not used,
# it will be number 0.
# - API.get_keyboard_state
# Returns a 256 byte string containing the virtual keys states.
# - API.get_keyboard_layout_name
# Returns a 9 byte string containing an id name of the keyboard layout.
# - API.vk_to_ascii(vk)
# Translates the given virtual key to an ASCII character.
# - API.get_pps(tag, id, file)
# Returns the value of the given id, of the given tag, of the given ini
# file.
# - API.get_window_placement([hwnd])
# Returns an array with the placement of the given window. If hwnd is not
# given, it will be used the rgss player.
# - API.get_cursor_pos
# Returns an unpacked mouse coordinates.
# - API.get_client_rect([hwnd])
# Returns an array containing the rect of the given window. If hwnd is not
# given, it will be the game window.
# ** Module Aleworks::Ini
# * Methods:
# - get_string(id[, tag[, file]])
# Returns the value of the given id, of the given tag, of the given ini
# file. If the tag is not given, it will be used 'Game', and if the file
# is not given, it will be used '.\\Game.ini'.
# - set_string(string, id[, tag[, file]])
# Writes the value to the given id, of the given tag, of the given ini
# file. If the tag is not given, it will be used 'Game', and if the file
# is not given, it will be used '.\\Game.ini'.
# ** Module Aleworks::Clipboard
# * Methods:
# - read
# Returns the data contained in the Windows Clipboard.
# - write(data)
# Writes 'data' to the Windows Clipboard.
# - empty
# Clears the data of the Windows Clipboard.
# ** Module Aleworks::Registry
# * Constants:
# - HKEYS
# Used internaly, for translate the strings HKEYS to numeric.
# * Methods:
# - read_entry(key, entry)
# Returns the value of the given entry, of the given key.
# - enum_keys(key)
# Returns an Array value containing all subkeys of the given key.
# - enum_entries(key)
# Returns an Array value containing all entries of the given key.
# ** Class Array
# * Methods:
# - clone_all
# Creates a copy of the object, and all it's sub values.
# - to_hash
# Creates a hash using the index of the values as the keys.
# - rindexes(*values)
# Returns the indices of all values contained in 'values'.
# - deep([deep])
# Returns the max count of the continuated sub contained arrays/hashs.
# 'deep' is the starting count + 1. If it is not given, will be used -1.
# Examples:
# - p [1, 2, 3].deep => 0
# - p [1, 2, [3]].deep => 1
# - p [[1], 2, [3]].deep => 1
# - p [[[1], 2, 3]].deep => 2
# - p [[[[[[1]]]]]].deep => 5
# - all_flatten; all_flatten!
# Similar to flatten, but it will affect the Hash, too. Used with ! will
# modify self.
# ** Class Hash
# * Methods:
# - clone_all
# Creates a copy of the object, and all it's sub values and keys.
# - deep([deep])
# See Array.deep.
# - fusion
# Returns an Array, where will be combined using '+' each key and value.
# If at least one key can't be combined with its value, will raise an
# Errno::EINVAL error.
# ** Class String
# * Methods:
# - pixel_width([size[, name]])
# Returns the width in pixel of the string.
# - pixel_height([size[, name]])
# Returns the height in pixel of the string.
# - width_slice(width[, size[, name]])
# Returns an Array containing Strings with theirs pixel_width, equal or
# less than width.
# - font_size_width(width[, name]])
# Returns the max font size, that will not cut the String when displayed
# with the given width. Returns nil, if no size is available.
# - font_size_height(height[, name]])
# Returns the max font size, that will not cut the String when displayed
# with the given height. Returns nil, if no size is available.
# - font_size(width, height[, name]])
# Returns the max font size, that will not cut the String when displayed
# with the given width and height. Returns nil, if no size is available.
# - trans_undrawable_chr([font[, chr]])
# Returns a string with all the undrawable characters for the given "font"
# replaced with "chr". If "font" is not given will be used the default font
# options. If "chr is not given, it will be "?".
# ** Class Bitmap
# * Alias method:
# - draw_text; Alias Name: alibrary_aleworks_bitmap_drawtext
# Allows to draw text using arrays, hashs, or other classes.
# - initialize
# If a block is given the Bitmap class will be returned and after the
# block ends the Bitmap will be disposed.
# - bmp_dump([filename[, background_color])
# Creates a ".bmp" file with the filename given from the Bitmap class. If
# filename is not given it will automatically maked. If background_color is
# given(as Color class) all the pixels from the Bitmap that have
# transparencies will be mixed with the given color.
# ** Module Graphics
# * Constants
# - Update
# Used for calling automaticaly methods when Graphics module is updated.
# For adding an auto-update, add an Array to the UPDATE array containg
# as first value the class/module as a Constant and as second value the
# method of the class/module to be updated as a symbol.
# * Alias method:
# - update; alibrary_aleworks_graphics_update
# Allows to update multiple frames using Graphics.update(frames), where
# frames are the count to be updated.
# ** Class Nil
# * Replaced method:
# - clone
# Removes the 'Nil can't be cloned error'.
#=============================================================================
#=============================================================================
# ** Module Aleworks
#=============================================================================
module Aleworks
module_function
#===========================================================================
# ** Module Aleworks::API
#===========================================================================
module API
module_function
#-------------------------------------------------------------------------
# APIs Definitions
#-------------------------------------------------------------------------
BlockInput = Win32API.new('user32', 'BlockInput', 'L', 'L')
ClientToScreen = Win32API.new('user32', 'ClientToScreen', 'LP', 'L')
CloseClipboard = Win32API.new('user32', 'CloseClipboard', '', 'L')
EmptyClipboard = Win32API.new('user32', 'EmptyClipboard', '', 'L')
GetActiveWindow = Win32API.new('user32', 'GetActiveWindow', '', 'L')
GetAsyncKeyState = Win32API.new('user32', 'GetAsyncKeyState', 'L', 'L')
GetClientRect = Win32API.new('user32', 'GetClientRect', 'LP', 'L')
GetClipboardData = Win32API.new('user32', 'GetClipboardData', 'L', 'L')
GetCursorPos = Win32API.new('user32', 'GetCursorPos', 'P', 'L')
GetDoubleClickTime = Win32API.new('user32', 'GetDoubleClickTime', '', 'L')
GetKeyboardLayout = Win32API.new('user32', 'GetKeyboardLayout','L', 'L')
GetKeyboardLayoutName =Win32API.new('user32','GetKeyboardLayoutName','P','L')
GetKeyboardState = Win32API.new('user32', 'GetKeyboardState', 'P', 'L')
GetKeyState = Win32API.new('user32', 'GetKeyState', 'L', 'L')
GetSystemMetrics = Win32API.new('user32', 'GetSystemMetrics', 'L', 'L')
GetWindowPlacement = Win32API.new('user32', 'GetWindowPlacement', 'LP', 'L')
Keybd_Event = Win32API.new('user32', 'keybd_event', 'LLLL', '')
OpenClipboard = Win32API.new('user32', 'OpenClipboard', 'L', 'L')
ScreenToClient = Win32API.new('user32', 'ScreenToClient', 'LP', 'L')
SetClipboardData = Win32API.new('user32', 'SetClipboardData', 'LL', 'L')
ShowCursor = Win32API.new('user32', 'ShowCursor', 'L', 'L')
ToAsciiEx = Win32API.new('user32', 'ToAsciiEx', 'LLPPLL', 'L')
GetCurrentProcessId = Win32API.new('kernel32','GetCurrentProcessId', '','L')
GPPSA = Win32API.new('kernel32', 'GetPrivateProfileStringA', 'PPPPLP', 'L')
WPPSA = Win32API.new('kernel32', 'WritePrivateProfileStringA', 'PPPP', 'L')
GlobalAlloc = Win32API.new('kernel32', 'GlobalAlloc', 'LL', 'L')
GlobalLock = Win32API.new('kernel32', 'GlobalLock', 'L', 'L')
GlobalSize = Win32API.new('kernel32', 'GlobalSize', 'L', 'L')
GlobalUnlock = Win32API.new('kernel32', 'GlobalUnlock', 'L', '')
RegCloseKey = Win32API.new('advapi32', 'RegCloseKey', 'L', 'L')
RegEnumKeyExA = Win32API.new('advapi32', 'RegEnumKeyExA', 'LLPPLLLP', 'L')
RegEnumValueA = Win32API.new('advapi32', 'RegEnumValueA', 'LLPPPPPP', 'L')
RegOpenKeyExA = Win32API.new('advapi32', 'RegOpenKeyExA', 'LPLLP', 'L')
RegQueryValueExA = Win32API.new('advapi32', 'RegQueryValueExA','LPLPPP', 'L')
begin
Memcpy = Win32API.new('ntdll', 'memcpy', 'PPL', 'L')
rescue
Memcpy = Win32API.new('crtdll', 'memcpy', 'PPL', 'L')
end
['3', '2', '1', '0'].each do |n|
_break = false
['E', 'J'].each do |l|
dll = 'RGSS10' + n + l
begin
RGSSGetRTPPath = Win32API.new(dll, 'RGSSGetRTPPath', 'L', 'L')
RGSSGetPathWithRTP = Win32API.new(dll, 'RGSSGetPathWithRTP', 'L', 'P')
_break = true
rescue
end
break if _break
end
break if _break
end
#-------------------------------------------------------------------------
# * Get RTP Path
#-------------------------------------------------------------------------
def get_rtp_path(rtp = 0)
RGSSGetPathWithRTP.call(RGSSGetRTPPath.cal(rtp))
end
#-------------------------------------------------------------------------
# * Get Keyboard Input State
#-------------------------------------------------------------------------
def get_keyboard_state
buffer = ' ' * 256
GetKeyboardState.call(buffer)
buffer
end
#-------------------------------------------------------------------------
# * Get Keyboard Layout Name
#-------------------------------------------------------------------------
def get_keyboard_layout_name
buffer = ' ' * 9
GetKeyboardLayoutName.call(buffer)
buffer.chop
end
#-------------------------------------------------------------------------
# * Virtual Key to String
#-------------------------------------------------------------------------
def vk_to_ascii(vk, alt_gr = false)
buffer = ' ' * 2
state = API.get_keyboard_state
if alt_gr
state[17, 1] = "\201"
state[18, 1] = "\201"
end
result = API::ToAsciiEx.call(vk, 0, state, buffer, 0,
API.get_keyboard_layout)
case result
when 1..2
buffer[0, 1]
else
''
end
end
#-------------------------------------------------------------------------
# * Get Private Profile String
#-------------------------------------------------------------------------
def get_pps(tag, id, file)
buffer = "\0" * 255
GPPSA.call(tag, id, '', buffer, 255, file)
buffer.delete!("\0")
end
#-------------------------------------------------------------------------
# * Get Window Placement
#-------------------------------------------------------------------------
def get_window_placement(hwnd = Aleworks::Active_Window)
buffer = [48].pack('L') + ' ' * 44
GetWindowPlacement.call(hwnd, buffer)
buffer.unpack('L11')
end
#-------------------------------------------------------------------------
# * Get Cursor Pos
#-------------------------------------------------------------------------
def get_cursor_pos
buffer = ' ' * 8
result = GetCursorPos.call(buffer)
if result != 0
buffer
else
nil
end
end
#-------------------------------------------------------------------------
# * Get Keyboard Layout
#-------------------------------------------------------------------------
def get_keyboard_layout
GetKeyboardLayout.call(0)
end
#-------------------------------------------------------------------------
# * Get Client Rect
#-------------------------------------------------------------------------
def get_client_rect(hwnd = Aleworks::Active_Window)
buffer = ' ' * 16
GetClientRect.call(hwnd, buffer)
buffer.unpack('L4')
end
end
#===========================================================================
# ** Module Aleworks::Ini
#===========================================================================
module Ini
module_function
#-------------------------------------------------------------------------
# * Get String from Ini File
#-------------------------------------------------------------------------
def get_string(id, tag = 'Game', file = '.\\Game.ini')
get_pps(tag, id, file)
end
#-------------------------------------------------------------------------
# * Write String to Ini File
#-------------------------------------------------------------------------
def set_string(string, id, tag = 'Game', file = '.\\Game.ini')
API::WPPSA.call(tag, id, string, file)
end
end
#===========================================================================
# ** Module Aleworks::Clipboard
#===========================================================================
module Clipboard
module_function
#-------------------------------------------------------------------------
# * Read Clipboard Data
#-------------------------------------------------------------------------
def read
API::OpenClipboard.call(0)
data = API::GetClipboardData.call(7)
API::CloseClipboard.call
return '' if data == 0
lp = API::GlobalLock.call(data)
len = API::GlobalSize.call(data)
data2 = ' ' * (len - 1)
API::Memcpy.call(data2, lp, len)
API::GlobalUnlock.call(data)
data2
end
#-------------------------------------------------------------------------
# * Write Data to Clipboard
#-------------------------------------------------------------------------
def write(data)
API::OpenClipboard.call(0)
API::EmptyClipboard.call
set_data = API::GlobalAlloc.call(66, data.length + 1)
len = [data.size + 1, API::GlobalSize.call(set_data)].min
lp = API::GlobalLock.call(set_data)
API::Memcpy.call(lp, "#{data}", len)
API::GlobalUnlock.call(set_data)
API::SetClipboardData.call(7, set_data)
API::CloseClipboard.call
end
#-------------------------------------------------------------------------
# * Clear Clipboard Data
#-------------------------------------------------------------------------
def empty
API::EmptyClipboard.call
end
end
#===========================================================================
# ** Module Aleworks::Registry
#===========================================================================
module Registry
module_function
HKEYS = {'HKEY_CLASSES_ROOT' => 0x80000000,'HKEY_CURRENT_USER' => 0x80000001,
'HKEY_LOCAL_MACHINE' => 0x80000002, 'HKEY_USERS' => 0x80000003,
'HKEY_CURRENT_CONFIG' => 0x80000005}
#-------------------------------------------------------------------------
# * Read an Entry
#-------------------------------------------------------------------------
def read_entry(key, entry)
key.sub!(/(.*?)\\/, '')
if HKEYS[$1] != nil
hkey = HKEYS[$1]
else
return nil
end
opened, type, size = [0].pack('V'), [0].pack('V'), [0].pack('V')
API::RegOpenKeyExA.call(hkey, key, 0, 131097, opened)
opened = (opened + [0].pack('V')).unpack('V')[0]
API::RegQueryValueExA.call(opened, entry, 0, type, 0, size)
data = ' ' * (size + [0].pack('V')).unpack('V')[0]
API::RegQueryValueExA.call(opened, entry, 0, type, data, size)
API::RegCloseKey.call(opened)
data = data[0, (size + [0].pack('V')).unpack('V')[0]]
type = (type += [0].pack('V')).unpack('V')[0]
case type
when 1
data.chop
when 2
data.chop.gsub(/%([^%]+)%/) { ENV[$1] || $& }
when 3
data
when 4
(data += [0].pack('V')).unpack('V')[0]
when 5
data.unpack('N')[0]
when 7
data.split(/\0/)
when 11
(data.unpack('VV')[1] << 32) | data[0]
else
nil
end
end
#-------------------------------------------------------------------------
# * Enum Keys
#-------------------------------------------------------------------------
def enum_keys(key)
key.sub!(/(.*?)\\/, '')
if HKEYS[$1] != nil
hkey = HKEYS[$1]
else
return nil
end
index, keys, opened = 0, [], [0].pack('V')
API::RegOpenKeyExA.call(hkey, key, 0, 131097, opened)
opened = (opened + [0].pack('V')).unpack('V')[0]
loop do
name = ' ' * 514
size = [514].pack('V')
result = API::RegEnumKeyExA.call(opened, index, name, size, 0, 0, 0, 0)
if result == 0
keys.push(name[0, (size += [0].pack('V')).unpack('V')[0]])
index += 1
else
break
end
end
API::RegCloseKey.call(opened)
keys
end
#-------------------------------------------------------------------------
# * Enum Entries
#-------------------------------------------------------------------------
def enum_entries(key)
key.sub!(/(.*?)\\/, '')
if HKEYS[$1] != nil
hkey = HKEYS[$1]
else
return nil
end
index, entries, opened = 0, [], [0].pack('V')
API::RegOpenKeyExA.call(hkey, key, 0, 131097, opened)
opened = (opened + [0].pack('V')).unpack('V')[0]
loop do
name = ' ' * 514
size = [514].pack('V')
result = API::RegEnumValueA.call(opened, index, name, size, 0, 0, 0, 0)
if result == 0
entries.push(name[0, (size += [0].pack('V')).unpack('V')[0]])
index += 1
else
break
end
end
API::RegCloseKey.call(opened)
entries
end
end
#---------------------------------------------------------------------------
# Variables Declaration
#---------------------------------------------------------------------------
Active_Window = API::GetActiveWindow.call
Current_Process_Id = API::GetCurrentProcessId.call
ASCII_TABLE = {1=>'?',2=>'?',3=>'?',4=>'?',5=>'?',6=>'?',7=>'?',8=>'?',9=>'?',
10=>'?',11=>'?',12=>'?',13=>'?',14=>'?',15=>'?',16=>'?',17=>'?',18=>'?',
19=>'?',20=>'?',21=>'?',22=>'?',23=>'?',24=>'?',25=>'?',26=>'?',27=>'?',
28=>'?',29=>'?',30=>'?',31=>'?',32=>' ',33=>'!',34=>'"',35=>'#',36=>'$',
37=>'%',38=>'&',39=>"'",40=>'(',41=>')',42=>'*',43=>'+',44=>',',45=>'-',
46=>'.',47=>'/',48=>'0',49=>'1',50=>'2',51=>'3',52=>'4',53=>'5',54=>'6',
55=>'7',56=>'8',57=>'9',58=>':',59=>';',60=>'<',61=>'=',62=>'>',63=>'?',
64=>'@',65=>'A',66=>'B',67=>'C',68=>'D',69=>'E',70=>'F',71=>'G',72=>'H',
73=>'I',74=>'J',75=>'K',76=>'L',77=>'M',78=>'N',79=>'O',80=>'P',81=>'Q',
82=>'R',83=>'S',84=>'T',85=>'U',86=>'V',87=>'W',88=>'X',89=>'Y',90=>'Z',
91=>'[',92=>'\\',93=>']',94=>'^',95=>'_',96=>'`',97=>'a',98=>'b',99=>'c',
100=>'d',101=>'e',102=>'f',103=>'g',104=>'h',105=>'i',106=>'j',107=>'k',
108=>'l',109=>'m',110=>'n',111=>'o',112=>'p',113=>'q',114=>'r',115=>'s',
116=>'t',117=>'u',118=>'v',119=>'w',120=>'x',121=>'y',122=>'z',123=>'{',
124=>'|',125=>'}',126=>'~',127=>'?',128=>'?',129=>'?',130=>'?',131=>'?',
132=>'?',133=>'?',134=>'?',135=>'?',136=>'?',137=>'?',138=>'?',139=>'?',
140=>'?',141=>'?',142=>'?',143=>'?',144=>'?',145=>'?',146=>'?',147=>'?',
148=>'?',149=>'?',150=>'?',151=>'?',152=>'?',153=>'?',154=>'?',155=>'?',
156=>'?',157=>'?',158=>'?',159=>'?',160=>'?',161=>'?',162=>'?',163=>'?',
164=>'?',165=>'?',166=>'?',167=>'?',168=>'?',169=>'?',170=>'?',171=>'?',
172=>'?',173=>'?',174=>'?',175=>'?',176=>'?',177=>'?',178=>'?',179=>'?',
180=>'?',181=>'?',182=>'?',183=>'?',184=>'?',185=>'?',186=>'?',187=>'+',
188=>'+',189=>'?',190=>'?',191=>'+',192=>'+',193=>'-',194=>'-',195=>'+',
196=>'-',197=>'+',198=>'?',199=>'?',200=>'+',201=>'+',202=>'-',203=>'-',
204=>'?',205=>'-',206=>'+',207=>'?',208=>'?',209=>'?',210=>'?',211=>'?',
212=>'?',213=>'i',214=>'?',215=>'?',216=>'?',217=>'+',218=>'+',219=>'?',
220=>'_',221=>'?',222=>'?',223=>'?',224=>'?',225=>'?',226=>'?',227=>'?',
228=>'?',229=>'?',230=>'?',231=>'?',232=>'?',233=>'?',234=>'?',235=>'?',
236=>'?',237=>'?',238=>'?',239=>'?',240=>'*',241=>'?',242=>'=',243=>'?',
244=>'?',245=>'?',246=>'?',247=>'?',248=>'?',249=>'?',250=>'?',251=>'?',
252=>'?',253=>'?',254=>'?',255=>' '}
TRANSLATE_TABLE = {"\225"=>'?',"\244"=>'?',"\266"=>'?',"\247"=>'?',"\307"=>'?',
"\374"=>'?',"\351"=>'?',"\342"=>'?',"\344"=>'?',"\340"=>'?',"\345"=>'?',
"\347"=>'?',"\352"=>'?',"\353"=>'?',"\350"=>'?',"\357"=>'?',"\356"=>'?',
"\354"=>'?',"\304"=>'?',"\305"=>'?',"\311"=>'?',"\346"=>'?',"\306"=>'?',
"\364"=>'?',"\366"=>'?',"\362"=>'?',"\373"=>'?',"\371"=>'?',"\377"=>'?',
"\326"=>'?',"\334"=>'?',"\370"=>'?',"\243"=>'?',"\330"=>'?',"\327"=>'?',
"\203"=>'?',"\341"=>'?',"\355"=>'?',"\363"=>'?',"\372"=>'?',"\361"=>'?',
"\321"=>'?',"\252"=>'?',"\272"=>'?',"\277"=>'?',"\256"=>'?',"\254"=>'?',
"\275"=>'?',"\274"=>'?',"\241"=>'?',"\253"=>'?',"\273"=>'?',"\301"=>'?',
"\302"=>'?',"\300"=>'?',"\251"=>'?',"\242"=>'?',"\245"=>'?',"\343"=>'?',
"\303"=>'?',"\244"=>'?',"\360"=>'?',"\320"=>'?',"\312"=>'?',"\313"=>'?',
"\310"=>'?',"\315"=>'?',"\316"=>'?',"\317"=>'?',"\314"=>'?',"\257"=>'?',
"\323"=>'?',"\337"=>'?',"\324"=>'?',"\322"=>'?',"\365"=>'?',"\325"=>'?',
"\265"=>'?',"\376"=>'?',"\336"=>'?',"\332"=>'?',"\333"=>'?',"\331"=>'?',
"\375"=>'?',"\335"=>'?',"\257"=>'?',"\264"=>'?',"\255"=>'*',"\261"=>'?',
"\276"=>'?',"\266"=>'?',"\247"=>'?',"\367"=>'?',"\270"=>'?',"\260"=>'?',
"\250"=>'?',"\267"=>'?',"\271"=>'?',"\263"=>'?',"\262"=>'?',"\240"=>' ',
"\t"=>' ',"\200"=>'?'}
#---------------------------------------------------------------------------
# * Get Current User Deskot Path
#---------------------------------------------------------------------------
def get_current_desktop_path
key = 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\'
Registry.read_entry(key + 'Explorer\\Shell Folders', 'Desktop')
end
#---------------------------------------------------------------------------
# * Get Current User Personal Folder Path
#---------------------------------------------------------------------------
def get_current_userdocuments_path
key = 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\'
Registry.read_entry(key + 'Explorer\\Shell Folders', 'Personal')
end
#---------------------------------------------------------------------------
# * Get Common Deskot Path
#---------------------------------------------------------------------------
def get_common_desktop_path
key = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\Windows\\CurrentVersion\\'
Registry.read_entry(key + 'Explorer\\Shell Folders', 'Common Desktop')
end
#---------------------------------------------------------------------------
# * Get Common Users Personal Folder Path
#---------------------------------------------------------------------------
def get_common_usersdocuments_path
key = 'HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\'
Registry.read_entry(key + 'Explorer\\Shell Folders', 'Common Documents')
end
#---------------------------------------------------------------------------
# * Get Fonts Folder Path
#---------------------------------------------------------------------------
def get_fonts_folder_path
key = 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\'
Registry.read_entry(key + 'Explorer\\Shell Folders', 'Fonts')
end
#---------------------------------------------------------------------------
# * Get Fonts Names
#---------------------------------------------------------------------------
def get_fonts_names
key = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\#{ENV['OS'].sub(/_/,' ')}\\"
fonts = Registry.enum_entries(key + 'CurrentVersion\\Fonts')
fonts.each_index {|f|
fonts[f].sub!(' (TrueType)', '')
fonts[f] = nil if !Font.exist?(fonts[f])
}.delete(nil)
fonts
end
#---------------------------------------------------------------------------
# * Get Mouse Swap Buttons Flag
#---------------------------------------------------------------------------
def get_mouse_swap_buttons_flag
key = 'HKEY_CURRENT_USER\\Control Panel\\Mouse'
Registry.read_entry(key, 'SwapMouseButtons').to_i
end
#---------------------------------------------------------------------------
# * Get Mouse Position
#---------------------------------------------------------------------------
def get_mouse_position
pos = API.get_cursor_pos
if pos.nil?
nil
else
pos.unpack('L2')
end
end
#---------------------------------------------------------------------------
# * Get Mouse Window Position
#---------------------------------------------------------------------------
def get_mouse_window_position(hwnd = Active_Window)
pos = API.get_cursor_pos
if pos.nil?
nil
else
result = API::ScreenToClient.call(hwnd, pos)
if result != 0
pos = pos.unpack('L2')
max_x, max_y = API.get_client_rect[2] - 1, API.get_client_rect[3] - 1
if pos[0] >= 0 and pos[1] >= 0 and pos[0] <= max_x and pos[1] <= max_y
pos
else
nil
end
else
nil
end
end
end
#---------------------------------------------------------------------------
# * Get Window Rect
#---------------------------------------------------------------------------
def get_window_rect(hwnd = Active_Window)
placement = API.get_window_placement(hwnd)[7..10]
width = placement[2] - placement[0]
height = placement[3] - placement[1]
[placement[0], placement[1], width, height]
end
#---------------------------------------------------------------------------
# * Get Keyboard Layout Name
#---------------------------------------------------------------------------
def get_keyboard_layout_name
id = API.get_keyboard_layout_name
key='HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Keyboard Layout'
name = Registry.read_entry(key + 's\\' + id, 'Layout Text')
initials = Registry.read_entry(key + '\\DosKeybCodes', id)
name = name.nil? ? '' : name
initials = initials.nil? ? '' :initials
[translate_string(name), translate_string(initials)]
end
#---------------------------------------------------------------------------
# * Get Keyboard Layout Name
#---------------------------------------------------------------------------
def translate_string(string, arrayed = false)
translation = []
string.each_chr do |c|
if TRANSLATE_TABLE.has_key?(c)
translation << TRANSLATE_TABLE[c]
else
translation << c
end
end
if arrayed
translation
else
translation.join
end
end
#---------------------------------------------------------------------------
# * check_hang_up
#---------------------------------------------------------------------------
def check_hang_up(time)
if time.sec <= Time.now.sec - 6 or time.min != Time.now.min
Graphics.update
Time.now
else
time
end
end
end
#=============================================================================
# ** Class Array
#=============================================================================
class Array
#---------------------------------------------------------------------------
# * Clone All
#---------------------------------------------------------------------------
def clone_all
cloned = self.clone
cloned.each_index do |i|
cloned
= cloned.clone_all rescue cloned.clone rescue cloned
end
cloned
end
#---------------------------------------------------------------------------
# * To Hash
#---------------------------------------------------------------------------
def to_hash
hash = Hash.new
self.each_index {|i| hash = self}
hash
end
#---------------------------------------------------------------------------
# * Reverse Indexes
#---------------------------------------------------------------------------
def rindexes(*values)
array = Array.new
self.each_index {|i| array.push(i) if values.include?(self)}
array
end
#---------------------------------------------------------------------------
# * Deep
#---------------------------------------------------------------------------
def deep(deep = -1)
tmp_deep = deep + 1
deep = tmp_deep
self.each do |i|
deep = i.deep(tmp_deep) if deep < i.deep(tmp_deep) rescue nil
end
deep
end
#---------------------------------------------------------------------------
# * Flatten All
#---------------------------------------------------------------------------
def all_flatten
array = self.clone_all
array.each_index do |i|
if array.is_a?(Hash)
array = array.to_a
end
array = array.all_flatten rescue array
end
array.flatten!
array
end
#---------------------------------------------------------------------------
# * Destructive Flatten All
#---------------------------------------------------------------------------
def all_flatten!
self.each_index do |i|
if self.is_a?(Hash)
self = self.to_a
end
self = self.all_flatten rescue self
end
self.flatten!
self
end
#---------------------------------------------------------------------------
# * Insert
#---------------------------------------------------------------------------
def insert(*args)
array = self.clone
to_insert = args[1, args.size - 1]
args[0] = [args[0], array.size - 1].min
return array.reverse.concat(to_insert).reverse if args[0] < 0
array[0..args[0]].concat(to_insert).concat(array[args[0] + 1...array.size])
end
end
#=============================================================================
# ** Class Bitmap
#=============================================================================
class Bitmap
#---------------------------------------------------------------------------
# * Initialize
#---------------------------------------------------------------------------
if @alibrary_aleworks_bitmap_initialize.nil?
alias_methodalibrary_aleworks_bitmap_initialize, :initialize)
@alibrary_aleworks_bitmap_initialize = true
end
def initialize(*args)
alibrary_aleworks_bitmap_initialize(*args)
if block_given?
yield self
self.dispose unless self.disposed?
end
end
#---------------------------------------------------------------------------
# * Draw Text
#---------------------------------------------------------------------------
unless self.method_defined?alibrary_aleworks_bitmap_drawtext)
alias_methodalibrary_aleworks_bitmap_drawtext, :draw_text)
end
def draw_text(*args)
if args.size.between?(2,3)
args[2] = 0 if args.size == 2
args[4] = args[1]
args[5] = args[2]
args[1] = args[0].y
args[2] = args[0].width
args[3] = args[0].height
args[0] = args[0].x
elsif args.size == 5
args[5] = 0
end
if args[4].is_a?(Array)
args[4].all_flatten!
args[4].each do |t|
t = t.nil? ? 'nil' : "#{t}"
width = args[2].nil? ? self.text_size(t).width : args[2]
height = args[3].nil? ? self.text_size('0').height : args[3]
self.draw_text(args[0], args[1], width, height, t, args[5])
args[1] += height
end
return
elsif args[4].is_a?(Hash)
args[4] = args[4].fusion
args[4].all_flatten!
args[4].each do |t|
t = t.nil? ? 'nil' : "#{t}"
width = args[2].nil? ? self.text_size(t).width : args[2]
height = args[3].nil? ? self.text_size('0').height : args[3]
self.draw_text(args[0], args[1], width, height, t, args[5])
args[1] += height
end
return
elsif !args[4].is_a?(String)
if args[4].to_s == ''
args[4] = args[4].inspect
else
args[4] = args[4].to_s
end
end
args[2] = args[2].nil? ? self.text_size(args[4]).width + 2 : args[2]
args[3] = args[3].nil? ? self.text_size('0').height + 2 : args[3]
alibrary_aleworks_bitmap_drawtext(*args)
end
#---------------------------------------------------------------------------
# * Bitmap Save in Bmp Format
#---------------------------------------------------------------------------
def bmp_dump(filename = nil, background_color = nil)
bmp = self
filename = "#{bmp.object_id}" if filename.nil?
filename += '.bmp' if File.extname(filename) != '.bmp'
if !background_color.nil?
temp_bmp = bmp.clone
rect = Rect.new(0, 0, temp_bmp.width, temp_bmp.height)
bmp = Bitmap.new(temp_bmp.width, temp_bmp.height)
bmp.fill_rect(rect, background_color)
bmp.stretch_blt(rect, temp_bmp, rect)
temp_bmp.dispose
Graphics.update
end
file = File.open(filename, 'wb')
file.write('BM')
file.write([54 + (bmp.width * bmp.height * 24) / 8].pack('L'))
file.write('ALEW')
file.write([54].pack('L'))
file.write([40].pack('L'))
file.write([bmp.width].pack('L'))
file.write([bmp.height].pack('L'))
file.write([1].pack('L')[0, 2])
file.write([24].pack('L')[0, 2])
file.write([0, 0, 0, 0, 0, 0].pack('L6'))
null_spaces = 0
if bmp.width / 4 != bmp.width / 4.0
if (bmp.width + 1) / 4 == (bmp.width + 1) / 4.0
null_spaces = 1
elsif (bmp.width + 2) / 4 == (bmp.width + 2) / 4.0
null_spaces = 2
elsif (bmp.width + 3) / 4 == (bmp.width + 3) / 4.0
null_spaces = 3
end
end
time = Time.now
last_porcentage = -1
for y in (-bmp.height + 1)..0
line = ''
for x in 0...bmp.width
color = bmp.get_pixel(x, y.abs)
line += [color.blue.to_i].pack('L')[0, 1]
line += [color.green.to_i].pack('L')[0, 1]
line += [color.red.to_i].pack('L')[0, 1]
time = Aleworks.check_hang_up(time)
if block_given?
porcentage = (((y + bmp.height) * bmp.width + x)) * 100
porcentage /= bmp.height * bmp.width
if porcentage > last_porcentage
yield porcentage
last_porcentage = porcentage
end
end
end
file.write(line)
time = Aleworks.check_hang_up(time)
end
file.close
end
end
#=============================================================================
# ** Class Hash
#=============================================================================
class Hash
#---------------------------------------------------------------------------
# * Clone All
#---------------------------------------------------------------------------
def clone_all
cloned = self.clone
cloned.each_key do |i|
cloned = cloned.clone_all rescue cloned.clone rescue cloned
end
cloned
end
#---------------------------------------------------------------------------
# * Deep
#---------------------------------------------------------------------------
def deep(deep = -1)
tmp_deep = deep + 1
key_deep = tmp_deep
value_deep = tmp_deep
self.each do |k, v|
key_deep = k.deep(tmp_deep) if key_deep < k.deep(tmp_deep) rescue nil
value_deep = v.deep(tmp_deep) if value_deep < v.deep(tmp_deep) rescue nil
end
if key_deep > value_deep
key_deep
else
value_deep
end
end
#---------------------------------------------------------------------------
# * To Array, combining Key and Value
#---------------------------------------------------------------------------
def fusion
array = self.sort
array.each_index do|i|
begin
array = array[0] + array[1]
rescue
raise Errno::EINVAL, "Can't fusion Hash"
end
end
end
end
#=============================================================================
# ** Nil Class
#=============================================================================
class NilClass
def clone;end
end
#=============================================================================
# ** Class String
#=============================================================================
class String
#---------------------------------------------------------------------------
# * Pixel Width of String
#---------------------------------------------------------------------------
def pixel_width(*args)
if args[0].is_a?(Font)
size = args[0].size
name = args[0].name
bold = args[0].bold
else
size = args[0].nil? ? Font.default_size : args[0]
name = args[1].nil? ? Font.default_name : args[1]
bold = args[2].nil? ? Font.default_bold : args[2]
end
pix = 0
Bitmap.new(1, 1) do |bitmap|
bitmap.font.name = name
bitmap.font.size = size
bitmap.font.bold = bold
pix = bitmap.text_size(self).width
end
pix
end
#---------------------------------------------------------------------------
# * Pixel Height of String
#---------------------------------------------------------------------------
def pixel_height(*args)
if args[0].is_a?(Font)
size = args[0].size
name = args[0].name
bold = args[0].bold
else
size = args[0].nil? ? Font.default_size : args[0]
name = args[1].nil? ? Font.default_name : args[1]
bold = args[2].nil? ? Font.default_bold : args[2]
end
pix = 0
Bitmap.new(1, 1) do |bitmap|
bitmap.font.name = name
bitmap.font.size = size
bitmap.font.bold = bold
pix = bitmap.text_size(self).height
end
pix
end
#---------------------------------------------------------------------------
# * Cut String to Strings with less or equal size than Width
#---------------------------------------------------------------------------
def width_slice(width, *args)
if args[0].is_a?(Font)
size = args[0].size
name = args[0].name
bold = args[0].bold
else
size = args[0].nil? ? Font.default_size : args[0]
name = args[1].nil? ? Font.default_name : args[1]
bold = args[2].nil? ? Font.default_bold : args[2]
end
result = ['']
txt = self.clone
txt = txt.cscan
Bitmap.new(1, 1) do |bitmap|
bitmap.font.name = name
bitmap.font.size = size
bitmap.font.bold = bold
txt.each_index do |i|
if txt.is_a?(String)
txt = [txt, bitmap.text_size(txt).width]
if txt.include?(txt[0])
txt.collect! do |e|
if e == txt[0]
txt
else
e
end
end
end
end
end
end
act_width = 0
loop do
if txt.size > 0
tmp_width = act_width + txt[0][1]
tmp_width += txt[1][1] if txt.size > 1
if width >= act_width + txt[0][1]
result[result.size - 1] += txt[0][0]
act_width += txt[0][1]
txt.delete_at(0)
else
result.push('')
act_width = 0
end
else
break
end
end
result
end
#---------------------------------------------------------------------------
# * Max Font Size for Width
#---------------------------------------------------------------------------
def font_size_width(width, *args)
if args[0].is_a?(Font)
name = args[0].name
bold = args[0].bold
else
name = args[0].nil? ? Font.default_name : args[0]
bold = args[1].nil? ? Font.default_bold : args[1]
end
size = 6
Bitmap.new(1, 1) do |bitmap|
bitmap.font.name = name
bitmap.font.bold = bold
for i in 6..96
bitmap.font.size = i
size = i if bitmap.text_size(self).width <= width
end
end
size
end
#---------------------------------------------------------------------------
# * Max Font Size for Height
#---------------------------------------------------------------------------
def font_size_height(height, *args)
if args[0].is_a?(Font)
name = args[0].name
bold = args[0].bold
else
name = args[0].nil? ? Font.default_name : args[0]
bold = args[1].nil? ? Font.default_bold : args[1]
end
size = 6
Bitmap.new(1, 1) do |bitmap|
bitmap.font.name = name
bitmap.font.bold = bold
for i in 6..96
bitmap.font.size = i
size = i if bitmap.text_size(self).height <= height
end
end
size
end
#---------------------------------------------------------------------------
# * Max Font Size for Width & Height
#---------------------------------------------------------------------------
def font_size(width, height, *args)
if args[0].is_a?(Font)
name = args[0].name
bold = args[0].bold
else
name = args[0].nil? ? Font.default_name : args[0]
bold = args[1].nil? ? Font.default_bold : args[1]
end
size = 6
Bitmap.new(1, 1) do |bitmap|
bitmap.font.name = name
bitmap.font.bold = bold
for i in 6..96
bitmap.font.size = i
if bitmap.text_size(self).width <= width and
bitmap.text_size(self).height <= height
size = i
end
end
end
size
end
#---------------------------------------------------------------------------
# * Insert
#---------------------------------------------------------------------------
def insert(*args)
string = self
to_insert = args[1, args.size - 1].join
args[0] = [args[0], string.size - 1].min
string[0..args[0]] + to_insert + string[args[0] + 1...string.size]
end
#---------------------------------------------------------------------------
# * Iterate each Character
#---------------------------------------------------------------------------
def each_chr
self.cscan.each {|chr| yield chr}
end
#---------------------------------------------------------------------------
# * Character Scan
#---------------------------------------------------------------------------
def cscan
chrs = []
for i in 0...self.size
chrs.push(self[i..i])
end
chrs
end
#---------------------------------------------------------------------------
# * One Character Scan
#---------------------------------------------------------------------------
def oscan
self.scan(/./)
end
#---------------------------------------------------------------------------
# * To ASCII Integer
#---------------------------------------------------------------------------
def to_ascii_i
self.unpack('B8')[0].to_i(2)
end
#---------------------------------------------------------------------------
# * Transform the undrawable Characters
#---------------------------------------------------------------------------
def trans_undrawable_chr(font = Font.new, chr = '?')
bmp = Bitmap.new(1, 1)
bmp.font= font
txt = ''
oscan.each {|c| txt += (bmp.text_size(c).width == 0) ? chr : c}
txt
end
end
#=============================================================================
# ** Module Graphics
#=============================================================================
module Graphics
Update = []
class << self
#-------------------------------------------------------------------------
# * Multiple Graphics update & objects update
#-------------------------------------------------------------------------
unless self.method_defined?alibrary_aleworks_graphics_update)
alias_methodalibrary_aleworks_graphics_update, :update)
end
def update(frames = 0)
alibrary_aleworks_graphics_update
Update.each {|k| k[0].method(k[1]).call}
update(frames - 1) if frames > 0
end
end
end
[/rgss]
Ahref:
[rgss]#=============================================================================
# ** HTML Link
#-----------------------------------------------------------------------------
# Draycos Goldaryn
# 1.05
# 07/02/07
# SDK Version : 2.2 - Part 1
#-----------------------------------------------------------------------------
# This script will allow you to include links to webpages within your game
# and will open these webpages in the player's default web browser.
# To do this, simply call the following command:
# A.href('name.of.webpage')
# and replace 'name.of.webage' with the address of the webpage. Make sure it
# is entered as a string.
# Examples:
# A.href('www.google.com') #Opens Google's homepage in the default browser
# A.href('http://www.google.com') # does the same
# A.href('http://google.com') # and again
# A.href('google.com') # yep, still Google's homepage
#=============================================================================
#-----------------------------------------------------------------------------
# * SDK Log Script
#-----------------------------------------------------------------------------
#SDK.log('HTML Link', 'Draycos Goldaryn', 1.05, '07/02/07')
#SDK.check_requirements(2.20, [1], {'Aleworks Library' => 1.00})
#-----------------------------------------------------------------------------
# * Begin SDK Enable Test
#-----------------------------------------------------------------------------
#if SDK.enabled?('HTML Link')
module A
#--------------------------------------------------------------------------
# ? instance variables
#--------------------------------------------------------------------------
attr_reader :browser
attr_reader :browser_path
#--------------------------------------------------------------------------
# ? initialize
#--------------------------------------------------------------------------
def initialize
@HLM = 'HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet'
@browser = Aleworks::Registry.read_entry(@HLM, '')
@HLM = 'HKEY_LOCAL_MACHINE' + '\\' + @HLM + '\\'
@HLM += @browser + '\shell\open\command'
@browser_path = Aleworks::Registry.read_entry(@HLM, '')
end
#--------------------------------------------------------------------------
# ? a.href('name.of.webpage')
#--------------------------------------------------------------------------
def href(link)
if link.is_a?(String)
Thread.start{system(@browser_path, link)}
else
print 'Invalid command. Webpage must be entered as a string.'
end
end
#--------------------------------------------------------------------------
# ? module functions
#--------------------------------------------------------------------------
module_function :initialize
module_function :href
end
A.initialize
#-----------------------------------------------------------------------------
# * End SDK Enable Test
#-----------------------------------------------------------------------------
#end
[/rgss]