Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

ScreenCapture X times per second during Y seconds


  • Please log in to reply
No replies to this topic
Varacolaci
  • Members
  • 3 posts
  • Last active: Feb 12 2016 10:31 PM
  • Joined: 21 Feb 2015

Hello, I was just playing around with the Gdip library and I made this little script to capture the screen.

The script can capture the entire screen a desired number of times per second (from 1 to around 8) during a defined lapse.

So you can capture your screen for example 2 times every second during 5 seconds and you'll get 10 screenshots.

 

Nothing fancy,but someone could find it usefull.

I made another script like this but it can capture up to 40 images per second but sadly its not yet ready to be shared (many weird bugs due the fast process of the images).

 

Well here is the script. it needs the Gdip library by tic

http://www.autohotke...ary-145-by-tic/

; Created 	by Cristo 
;			for ObsessedDesigns Studios™, Inc.
; Version 	1.0.2.1
; Built 	1331.0620.2015
; 	


;#####################################################################################
; OPTIMIZATIONS
;#####################################################################################
;http://ahkscript.org/boards/viewtopic.php?f=6&t=6413
#NoEnv
Process, Priority, , H
SetBatchLines, -1
ListLines Off
#KeyHistory 0
SendMode Input
SetTitleMatchMode 2
SetTitleMatchMode Fast
SetKeyDelay, -1, -1, Play
SetMouseDelay, -1
SetWinDelay, 0
;#####################################################################################
; INCLUDES
;#####################################################################################
#Include, inc\Gdip.ahk

;#####################################################################################
; INITIALIZATION - TERMINATION CODE
;#####################################################################################
pToken := Gdip_Startup()
OnExit, shutdown

;#####################################################################################
; GLOBAL VARIABLES
;#####################################################################################
fPath := A_ScriptDir "\GameShots\"	; folder in which your images will be saved
time2Cap := 5						; time to keep capturing [in seconds]
capPerSec := 2						; [1~10] times per second the screen will be captured
format := "png" 					; available formats JPG, PNG, BMP
quality := 125						; image quality
prefix := "img-"					; prefix to use as name
sufix := ""							; sufix to use as name
namingConvention := A_YYYY "-" A_MM "-" A_DD "_" A_Hour "." A_Min "." 

; internal variables. DO NOT EDIT
nCap := 0
nCap2 = 1

;create the base directory
IfNotExist, %fPath%
	FileCreateDir, %fPath%

waiting:

Loop {
	KeyWait, F9, D T0.02 		; edit this to fit your taste
    If not ErrorLevel
    {
		Goto, captureScreen
	}
	KeyWait, F4, D T0.02 		; edit this to fit your taste
	If not ErrorLevel
	{
		Goto, shutdown
	}
}

CaptureScreen:
run csFx.ahk
sTime := A_TickCount			; sets the start time of the capture
eTime := A_TickCount 			; read the time to complete the while

While sTime + (time2Cap*1000) > eTime
{	
	nCap := nCap + 1
	pBitmap%nCap% := Gdip_BitmapFromScreen(0, 0x40000000 + 0x00CC0020)
	if (nCap2 < 10 )
		nCap2 := "00" nCap2
		else if (nCap2 < 100 && nCap2 > 9)
			nCap2 := "0" nCap2
	if capPerSec > 1
	{
		fileName := prefix namingConvention A_TickCount sufix "." format
	} else
		fileName := prefix namingConvention sufix  "." format
	

	saveFileTo := fPath fileName
	if format = jpg
		Gdip_SaveBitmapToFile(pBitmap%nCap%, saveFileTo, quality)
		else
			Gdip_SaveBitmapToFile(pBitmap%nCap%, saveFileTo)

	nCap2 := nCap2 + 1
	;cleanup
	Gdip_DisposeImage(pBitmap%nCap%)
	DeleteObject(pBitmap%nCap%)
	DeleteObject(ErrorLevel)
	
	KeyWait, F8, D T0.01 
	If not ErrorLevel
	{	
		MsgBox, Stoped
		Goto, waiting
	}
	eTime2 := A_TickCount 				;read the time to complete the while
	sT := eTime2 - eTime
	sT := (1000 / capPerSec) - sT
	Sleep, sT
	eTime := A_TickCount			 	;read the time to complete the while
}
Goto, waiting

shutdown:
	Gdip_Shutdown(pToken)
	Exitapp
	return