Graphics.snap_to_bitmap VX function to XP.

Is there a script(already) which can take a screenshot of the game window and load it like the Graphics.snap_to_bitmap function in VX?
  1. module Graphics
  2.   RtlMoveMemory          = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
  3.   BitBlt                 = Win32API.new('gdi32', 'BitBlt', 'iiiiiiiii', 'i')
  4.   CreateCompatibleBitmap = Win32API.new('gdi32', 'CreateCompatibleBitmap', 'iii', 'i')
  5.   CreateCompatibleDC     = Win32API.new('gdi32', 'CreateCompatibleDC', 'i', 'i')
  6.   DeleteObject           = Win32API.new('gdi32', 'DeleteObject', 'i', 'i')
  7.   GetDIBits              = Win32API.new('gdi32', 'GetDIBits', 'iiiiipi', 'i')
  8.   SelectObject           = Win32API.new('gdi32', 'SelectObject', 'ii', 'i')
  9.   SetDIBits              = Win32API.new('gdi32', 'SetDIBits', 'iiiiipi', 'i')
  10.   hWnd = Win32API.new('user32', 'FindWindow', 'pp', 'i').call('RGSS Player', 0)
  11.   DC   = Win32API.new('user32', 'GetDC', 'i', 'i').call(hWnd)
  12.   def self.snap_to_bitmap
  13.     bitmap = Bitmap.new(width=640, height=480)
  14.     RtlMoveMemory.call(address="\0"*4, bitmap.__id__*2+16, 4)
  15.     RtlMoveMemory.call(address, address.unpack('L')[0]+8, 4)
  16.     RtlMoveMemory.call(address, address.unpack('L')[0]+16, 4)
  17.     address = address.unpack('L')[0]
  18.     info = [40,width,height,1,32,0,0,0,0,0,0].pack('LllSSLLllLL')
  19.     hDC = CreateCompatibleDC.call(DC)
  20.     hBM = CreateCompatibleBitmap.call(DC, width, height)
  21.     DeleteObject.call(SelectObject.call(hDC, hBM))
  22.     SetDIBits.call(hDC, hBM, 0, height, address, info, 0)
  23.     BitBlt.call(hDC, 0, 0, width, height, DC, 0, 0, 0xCC0020)
  24.     GetDIBits.call(hDC, hBM, 0, height, address, info, 0)
  25.     DeleteObject.call(hBM)
  26.     DeleteObject.call(hDC)
  27.     bitmap
  28.   end
  29. end
Expand to see the code.
Thank you very much!
Man, this is gonna be useful even to me *-*
Thank you very much!
Hi, sorry to necropost, but who would I credit for that really useful snippet?

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=75650