Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: G_G on June 12, 2010, 07:45:24 pm

Title: [XP] Snapshot
Post by: G_G on June 12, 2010, 07:45:24 pm
Snapshot
Authors: game_guy
Version: 1.0
Type: Picture Taking Script
Key Term: Misc Add-on



Introduction

Ever wanted to take screenies or snapshots ingame? While there are other methods of doing that, this one is by far the easiest. With a simple button press or script call, it'll take a screenshot of the game for you and save it in a folder.
Also useful for beta testing. Your testers can snapshot bugs or errors in mapping or stuff like that.


Features




Screenshots

Here's how well the pictures come out. No windows borders or anything.
Spoiler: ShowHide
(http://i678.photobucket.com/albums/vv143/GameGuysProjects/snap_5.png)



Demo

Download (http://decisive-games.com/ggp/scripts/Snapshot.exe)


Script

You'll also need the screenshot.dll (http://decisive-games.com/ggp/scripts/screenshot.dll) for this script to function correctly.
Spoiler: ShowHide

#===============================================================================
# Snapshot
# Author game_guy
# Version 1.0
#-------------------------------------------------------------------------------
# Intro:
# Ever wanted to take screenies or snapshots ingame? While there are other
# methods of doing that, this one is by far the easiest. With a simple button
# press or script call, it'll take a screenshot of the game for you and
# save it in a folder.
# Also useful for beta testing. Your testers can snapshot bugs or errors in
# mapping or stuff like that.
#
# Features:
# Take picture with button press or script call
# Customizable Button to press
#
# Instructions:
# Place screenshot.dll in your projects folder.
# Get the dll here if you need it
# http://decisive-games.com/ggp/scripts/screenshot.dll
# Make a folder in your projects folder called Snapshots
#
# Go down to the line where it says SnapShot_Key = Input::A
# You can change Input::A to any of the following
# Input::A - Usually the Shift Key
# Input::B - Usually the X or Escape key
# Input::C - Usually C, Enter, or Space
# Input::X - Usually the A Key
# Input::Y - Usually the S Key
# Input::Z - Usually the D Key
# Input::L - Usually the Q Key
# Input::R - Usually the W Key
# Input::SHIFT
# Input::CTRL
# Input::ALT
# Input::F5
# Input::F6
# Input::F7
# Input::F8
# Input::F9
#
# To take a snapshot with a script call use this
# GameGuy.snap thats it!
#
# Compatibility:
# Not tested with SDK. (Should work though)
# Will work with anything.
#
# Credits:
# game_guy ~ For making it
# Google ~ Searching up Win32Api tutorials
# Screenshot.dll ~ Whoever made this, made this script possible
#===============================================================================
module GameGuy
 SnapShot_Key = Input::A # Shift Key
 def self.snap
   snp = Win32API.new('screenshot.dll', 'Screenshot', %w(l l l l p l l), '')
   window = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')
   ini = (Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p),
     'l')
   game_name = "\0" * 256
   ini.call('Game', 'Title', '', game_name, 255, '.\Game.ini')
   game_name.delete!('\0')
   win = window.call('RGSS Player', game_name)
   dir = Dir.new("Snapshots/")
   count = 0
   dir.entries.each {|i| count += 1}
   file_name = "Snapshots/snap_#{count}.png"
   snp.call(0, 0, 640, 480, file_name, win, 2)
 end
end
module Input
 class << self
   alias gg_update_input_snapshot_lat update
 end
 def self.update
   if Input.trigger?(GameGuy::SnapShot_Key)
     GameGuy.snap
   end
   gg_update_input_snapshot_lat
 end
end



Instructions

In the script. Its recommended to place this above main but below everything else. It shouldn't cause issues with anything.


Compatibility

Not tested with SDK. (Should work anyways)
Should work with everything.


Credits and Thanks




Author's Notes

Enjoy!
Title: Re: [XP] Snapshot
Post by: Spaceman McConaughey on June 12, 2010, 07:56:12 pm
Epic script is epic. <3

*lvls up*
Title: Re: [XP] Snapshot
Post by: WhiteRose on June 12, 2010, 07:58:13 pm
G_G, do you know what this means? No more walking through people on how to use the Print Screen button. Good times... goooooooood times....
Title: Re: [XP] Snapshot
Post by: G_G on June 12, 2010, 08:04:22 pm
Lawl! Hahaha thanks!
Title: Re: [XP] Snapshot
Post by: Blizzard on June 13, 2010, 04:16:59 am
Lol, been there, done that. xD I think 50% of the more experienced scripters made a script using the Screenshot.dll. xD
BTW, Andreas21 made the DLL.
Title: Re: [XP] Snapshot
Post by: G_G on June 13, 2010, 10:19:04 am
Scripters may have made one, but I never seen one release one D:

Updated credits
Title: Re: [XP] Snapshot
Post by: Blizzard on June 13, 2010, 11:27:34 am
I think I actually posted one a long time ago.
Title: Re: [XP] Snapshot
Post by: G_G on June 13, 2010, 11:35:33 am
.___. why is it most of my scripts are of utter uselessness or have already been made
Title: Re: [XP] Snapshot
Post by: Blizzard on June 13, 2010, 01:19:55 pm
Bullshit. It's not useless. And plenty of scripts I made were already made as well. My Party Switcher, my Stat Distribution System, the screenshot script (yeah, there were some around before my time), ABS, online system, etc.
What I'm trying to say is that you should take a look at my code. You might learn something or get an idea how to improve your code. Or not if my code sucks.
Title: Re: [XP] Snapshot
Post by: G_G on June 13, 2010, 01:27:14 pm
Where is your screenshot script? Is it in the dev pack?
Title: Re: [XP] Snapshot
Post by: Blizzard on June 13, 2010, 01:46:26 pm
No. And I actually can't find it posted here anywhere. O_o
I found this in an old backup, though. The main thing to do would be to change the script so it aliases module Input rather than having to edit every possible scene. >.<

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Screenshot Kit
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Credits:
#  
#   screenshot.dll                  - Andreas21
#   calling script and instructions - Blizzard
#
#
# Instructions:
#  
#   Place the screenshot.dll in your game's main folder. To make a screenshot
#   system adding a code line in every Scene_SOMETHING script. Usually
#   part of the script looks like this:
#  
#     class Scene_SOMETHING
#       def main
#         ...
#         loop do
#           Graphics.update
#           Input.update
#           ### HERE COMES THE EXTRA LINE!
#           update
#           if $scene != self
#             break
#           end
#         end
#         ...
#       end
#     end
#  
#   The extra line that you need to add has to look like this:
#  
#     Screen.shot if Input.trigger?(Input::KEY)
#  
#   KEY - the key that is being pressed to take a screenshot
#  
#   Keep in mind that you can only use RMXP's predefined keys (like A, X, Y, Z,
#   F5, F6, etc.). If you are using Blizz-ABS or Custom Game Controls from Tons
#   of Add-ons, you can use any key (Key['Arrow Up'], Key['U'], etc.). If you
#   have another custom controls script, you can use on of its keys instead.
#  
#  
# Note:
#  
#   Your files will be saved as:
#  
#     "PATH" + "FILENAME" + "DD.MM.YYYY HH-MM-SS" + "EXTENSION"
#  
#   DD.MM.YYYY - date
#   HH-MM-SS   - time
#  
#   Keep in mind that making two screenshots in one second will result the
#   previous screenshot to be deleted.
#  
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

module Screen
 
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 # folder where screenshots are placed, leave empty for main folder
 PATH = 'Screenshots/'
 # basic filenames
 FILENAME = 'My Game @ '
 # file extension/format (0 = BMP, 1 = JPG, 2 = PNG)
 EXTENSION = 2
 # sound effect to be played (leave FILENAME empty for none)
 # template:   RPG::AudioFile.new('FILENAME', VOLUME, PITCH)
 SOUND = RPG::AudioFile.new('snap', 80, 100)

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

#==============================================================================
# module RPG::Cache
#==============================================================================

 @screen = Win32API.new 'screenshot.dll', 'Screenshot', %w(l l l l p l l), ''
 @readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l'
 @findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
 
 def self.shot
   game_name = "\0" * 256
   @readini.call('Game', 'Title', '', game_name, 255, './Game.ini')
   game_name.delete!("\0")
   window = @findwindow.call('RGSS Player', game_name)
   time = Time.new
   extension = case EXTENSION
   when 0 then '.bmp'
   when 1 then '.jpg'
   when 2 then '.png'
   end
   @screen.call(0, 0, 640, 480, time.strftime(
       PATH + FILENAME + '%d.%m.%Y %H-%M-%S' + extension), window, EXTENSION)
   if SOUND.name != ''
     Audio.se_play('Audio/SE/' + SOUND.name, SOUND.volume, SOUND.pitch)
   end
 end
 
end


I hope it's not buggy. O.o;
Title: Re: [XP] Snapshot
Post by: G_G on June 13, 2010, 01:54:49 pm
In a sense, mines more efficient, but yours has a few more features mine didn't. On top of that, if you were to code this from scratch now you would have already new to alias Input.update. Believe me, if I saw this here already, I wouldn't have made it. Well maybe I would have who knows xD
Title: Re: [XP] Snapshot
Post by: Blizzard on June 13, 2010, 03:53:03 pm
I really can't remember where it was posted. I probably just put it in the middle of a topic or something. xD
As I said, there's nothing wrong with you posting this. :)

EDIT: BTW, getting the window handler ID with @findwindow should be done only once at the initialization of the game. Best you put it in a constant and use it later when you make the screenshot. This speeds things up because two API calls don't need to be done each time. (I'm referring to my code, not yours.)
Title: Re: [XP] Snapshot
Post by: lonely_cubone on June 13, 2010, 04:04:46 pm
This is really useful, even if Blizz apparently made it already! Way faster, easier, and more efficient than Print Screen :D. *lvls*
Title: Re: [XP] Snapshot
Post by: G_G on June 13, 2010, 05:03:19 pm
thanks!

@blizz: I understand. I think you've also said this to me a few other times in the past xD
Title: Re: [XP] Snapshot
Post by: Ryex on June 13, 2010, 07:52:53 pm
now G_G take this script and make a save game menu with screen shotsshots script
Title: Re: [XP] Snapshot
Post by: Jragyn on June 13, 2010, 08:22:00 pm
I've seen one for VX that did the savescreen screenshot thing, minus characters o.O

It doesn't have the screenshot.dll tho, how does that work?


--J
Title: Re: [XP] Snapshot
Post by: lonely_cubone on June 13, 2010, 09:50:42 pm
Quote from: Ryexander on June 13, 2010, 07:52:53 pm
now G_G take this script and make a save game menu with screen shotsshots script


That would be really helpful. I don't think it'd be too hard, although I have no clue how to do it :n00b:
Seriously though, that would be a great script.
Title: Re: [XP] Snapshot
Post by: G_G on June 13, 2010, 11:52:35 pm
stop giving me script ideas D:

I might do something like that. Who knows.
Title: Re: [XP] Snapshot
Post by: Valdred on June 14, 2010, 12:13:26 pm
Would you permit me to use this script in a camera-script I am making for my game? Credit will be given of course.
Title: Re: [XP] Snapshot
Post by: G_G on June 14, 2010, 03:05:30 pm
Sure no problem!
Title: Re: [XP] Snapshot
Post by: G_G on June 19, 2010, 11:54:42 am
Quote from: jragyn00 on June 13, 2010, 08:22:00 pm
I've seen one for VX that did the savescreen screenshot thing, minus characters o.O

It doesn't have the screenshot.dll tho, how does that work?


--J


VX already has a built in snapshot thing I think.
Title: Re: [XP] Snapshot
Post by: Taiine on August 31, 2010, 06:58:33 am
Demo and dl for the .dll are missing. Would like an reupload please :3
Title: Re: [XP] Snapshot
Post by: Holyrapid on August 31, 2010, 10:40:35 am
I have the dll for reason unknown... But i don't have the demo...
Title: Re: [XP] Snapshot
Post by: bigace on September 22, 2011, 01:39:14 am
Sorry to necropost but the demo and .dll links are missing. :???:
Title: Re: [XP] Snapshot
Post by: G_G on September 22, 2011, 08:31:13 am
Here.
http://www.sendspace.com/file/aiirus
Title: Re: [XP] Snapshot
Post by: bigace on September 24, 2011, 03:39:19 pm
Quote from: game_guy on September 22, 2011, 08:31:13 am
Here.
http://www.sendspace.com/file/aiirus

Thank you