[XP] Snapshot

Started by G_G, June 12, 2010, 07:45:24 pm

Previous topic - Next topic

G_G

June 12, 2010, 07:45:24 pm Last Edit: June 13, 2010, 10:18:38 am by game_guy
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


  • Take picture with button press or script call
  • Customizable Button to press



Screenshots

Here's how well the pictures come out. No windows borders or anything.
Spoiler: ShowHide



Demo

Download


Script

You'll also need the 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


  • game_guy ~ For making it
  • Google ~ Searching up Win32Api tutorials
  • Andreas21 ~ Making screenshot.dll



Author's Notes

Enjoy!

Spaceman McConaughey

Epic script is epic. <3

*lvls up*

WhiteRose

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....

G_G


Blizzard

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.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

Scripters may have made one, but I never seen one release one D:

Updated credits

Blizzard

I think I actually posted one a long time ago.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

.___. why is it most of my scripts are of utter uselessness or have already been made

Blizzard

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.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

Where is your screenshot script? Is it in the dev pack?

Blizzard

June 13, 2010, 01:46:26 pm #10 Last Edit: June 13, 2010, 01:48:43 pm by Blizzard
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;
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

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

Blizzard

June 13, 2010, 03:53:03 pm #12 Last Edit: June 13, 2010, 03:55:24 pm by Blizzard
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.)
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

lonely_cubone

This is really useful, even if Blizz apparently made it already! Way faster, easier, and more efficient than Print Screen :D. *lvls*

G_G

thanks!

@blizz: I understand. I think you've also said this to me a few other times in the past xD

Ryex

now G_G take this script and make a save game menu with screen shotsshots script
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Jragyn

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
A bright light can either illuminate or blind, but how will you know which until you open your eyes?

earthnite

i ran to the shimmering light in the darkness--only to find a freight train coming my way

lonely_cubone

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.

G_G

stop giving me script ideas D:

I might do something like that. Who knows.