December 04, 2020, 11:12:29 AM

Author Topic: [bb] Smart ScreenShot Taker by Kozmi [ 1+ years ago ]  (Read 579 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Smart ScreenShot Taker by Kozmi [ 1+ years ago ]
« on: June 29, 2017, 12:28:38 AM »
Title : Smart ScreenShot Taker
Author : Kozmi
Posted : 1+ years ago

Description : The function will take a screenshot and remember the last
screenshot taken through that of a data file which the
function creates to obtain the last screenshot taken!
You can also specify a directory where you want the screenshots to be put at as well. This function is very useful for any application where you might need to take screenshots on a regular basis and don't wont to lose existing screenshots! I hope you find this code useful like i have.


Code :
Code: BlitzBasic
  1. Global Int1%    ;For writing to our '.egl' datafile
  2.  
  3. ;hit spacebar to save a screenshot
  4. If KeyHit(57) = True Then Screenshot()
  5.  
  6.  
  7. Function Screenshot()
  8.  
  9.         ChangeDir "E:Blitz3DBlitz3D Demosfpstestegyptian levelScreenShots"
  10.        
  11.                         screenin = ReadFile("screenshot.egl") ; you can change the extension to whatever you want!
  12.                         If screenin = 0 Then currentshot = 0:Goto phase2
  13.                         currentshot = ReadInt( screenin )
  14.                                   CloseFile( screenin )
  15.        
  16. .phase2         iFileNumber% = currentshot
  17.             Repeat
  18.                 iFileNumber = iFileNumber + 1
  19.                 sFileName$ = "Egyptian_Level" + String$("0", 3 - Len(Str$(iFileNumber))) + iFileNumber + ".bmp"
  20.             Until Not(FileType(sFileName))
  21.  
  22.         Int1 = iFileNumber     
  23.                
  24.                         screenout = WriteFile("screenshot.egl") ; Same as above!
  25.                         WriteInt( screenout, Int1 )
  26.                                   CloseFile( screenout )
  27.    
  28.     SaveBuffer FrontBuffer(), sFileName
  29.  
  30.         ChangeDir "E:Blitz3DBlitz3D Demosfpstestegyptian level" ; Change back to previous directory
  31.  
  32. End Function


Comments :


Rob Farley(Posted 1+ years ago)

 Would it not be easier...
Code: [Select]
SaveBuffer FrontBuffer(), "Screenshot " + currentdate() + " " + currenttime() + ".bmp"This will also date/time stamp your screenies.This is only a problem if you're going to take a screenshot faster than every second or for over a 100 year period, even then you could stick a millisecs() on the end to fix that problem.


Kozmi(Posted 1+ years ago)

 Well... Your example code is fine for what it does in all..But what if you don't want your screenshots cluttering up along with your other media files? This is where this is nice, Because this function will allow you to store thescreenshots into another directory plus also remember the last screenshot taken so that it wont over write an existingscreenshot(s) that you may want to keep for some reason or another?! I realize your code could also be changed to store into a different directory as well... But this code I posted does serve it's purpose too! People can use this as they wish to... Or they can use your's... It doesn't matter though, Because I created this yesterday for a test-demo I was working with, And I thought I would post it to share with others on here... They are free to use this if they want! :)


Rob Farley(Posted 1+ years ago)

 Glenn,The code modification to put screenies into another dir would be
Code: [Select]
SaveBuffer FrontBuffer(), "[YOUR DIR]/Screenshot " + currentdate() + " " + currenttime() + ".bmp"Which is a fairly basic change.Furthermore this would create unique filenames as long as you don't take screenshots for over 100 years or quicker than every second as I mentioned above. You can easily tell what the last file is as it is the one with the most recent time, or indeed click on the last modified heading in windows explorer to sort them.I'm not attacking your work just presenting what I believe to be a more elegant solution.


Kozmi(Posted 1+ years ago)

 Ok Rob,Your code is more simple & straight forward and all...But what if I don't want a time/data stamp? But I merly just want to include a name plus a number instead then?Im' sure you could write another example showing a more simplier way to do this as well... But the fact here is,even known my code has a little bit more to it as far asprogramming steps are concerned and all... It still serve's its purpose!!! Plus this code isn't that bad either! It may not be a simple one-liner like yours!! But it does have a nice setup as well! Plus if someone wanted to learn how to create a data file to read & write information too... At least this shows a starting point! Like I said above as well. This code work's fine for me, and I merly wanted to share it with other Blitz users on here! If they feel it isn't worth the bother and all... They don't have to download it, Or copy & paste it! they are free to use this code here... or your's if they perfer!The point here is... they both do the same thing! And that's all that matters here!


tesuji(Posted 1+ years ago)

 HiCurrenttime() outputs colons which are not valid windows filesystem characters.
Code: [Select]
SaveBuffer FrontBuffer(), "dir/filename-"+MilliSecs() + ".bmp"Works for me ;-pBoth techniques have their merits I'm sure.Cheers,S.


Rob Farley(Posted 1+ years ago)

 
Code: [Select]
filename$ = "dir/screenshot "+CurrentDate() + " " + Left(CurrentTime(),2)+Mid(CurrentTime(),4,2)+Right(CurrentTime(),2)+".bmp"

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal