FindWindow = Win32API.new "user32.dll", "FindWindow", %w{L P}, "L" GetDC = Win32API.new "user32.dll", "GetDC", 'L', "L" GetPixel = Win32API.new "gdi32.dll", "GetPixel", %w{L L L}, "L" TitleName = File.read("Game.ini").match(/Title=(\S+)$/)[1] GameHwnd = FindWindow.call(0, TitleName) GameDC = GetDC.call(GameHwnd) p "TitleName=#{TitleName}" p "GameHwnd=#{GameHwnd}" p "GameDC=#{GameDC}" def get_game_pixel(x, y) color_ref = GetPixel.call(GameDC, x, y) b = (color_ref & 0xFF0000) >> 8 * 2 g = (color_ref & 0x00FF00) >> 8 * 1 r = color_ref & 0x0000FF color = Color.new(r,g,b) end
FindWindow = Win32API.new "user32.dll", "FindWindow", %w{L P}, "L"
GetDC = Win32API.new "user32.dll", "GetDC", 'L', "L"
GetPixel = Win32API.new "gdi32.dll", "GetPixel", %w{L L L}, "L"
TitleName = File.read("Game.ini").match(/Title=(\S+)$/)[1]
GameHwnd = FindWindow.call(0, TitleName)
GameDC = GetDC.call(GameHwnd)
p "TitleName=#{TitleName}"
p "GameHwnd=#{GameHwnd}"
p "GameDC=#{GameDC}"
def get_game_pixel(x, y)
color_ref = GetPixel.call(GameDC, x, y)
b = (color_ref & 0xFF0000) >> 8 * 2
g = (color_ref & 0x00FF00) >> 8 * 1
r = color_ref & 0x0000FF
color = Color.new(r,g,b)
end
|