Sign in to follow this  
Followers 0
jabhacksoul

Area Capture "converting my program"?

2 posts in this topic

I do a LOT of tutorials where I take many screen shots. So I thought it would be cool to have a program that captures the full screen and a tight shot around the mouse every time I click a button. This has allowed me to vastly speed up the tutorial creation process without having to remember to take a picture.

So I made this to capture still images;

;Area Capture by Jabhacksoul (2011)
;A simple screen capture program
#include <ScreenCapture.au3>
#Include <Constants.au3>
Global $hUser32 = DllOpen ("User32.dll")
 
If Not FileExists (@MyDocumentsDir & '\Areashots\') Then DirCreate (@MyDocumentsDir & '\Areashots\')
MsgBox (1,'Area Capture','Images will be saved to the My Documents\Areashots folder. Use Esc button to exit this program.')
HotKeySet ("{ESC}","terminate")
Opt("TrayMenuMode",1)
TraySetState ()
TraySetTooltip ("Area Capture")
$radio1 = TrayCreateItem("Only Full Screen", -1, -1, 1)
$radio2 = TrayCreateItem("Only Tight Shot", -1, -1, 1)
$radio3 = TrayCreateItem("Capture Both", -1, -1, 1)
TrayItemSetState(-1, 1)
$radio7 = TrayCreateItem("Sequence", -1, -1, 1)
$FullCap = True
$TightCap = True
TrayCreateItem("")  ; Radio menuitem groups can be separated by a separator line or another norma menuitem
$radio4 = TrayCreateItem("Small 240x180", -1, -1, 1)
$radio5 = TrayCreateItem("Medium 480x360", -1, -1, 1)
TrayItemSetState(-1, 1)
$radio6 = TrayCreateItem("Large 640x480", -1, -1, 1)
TrayCreateItem("")
$Pause = TrayCreateItem("Pause")
TrayCreateItem("")
$Exit = TrayCreateItem("Exit")
TraySetState()
$Ax = 240
$Ay = 180
$Bx = 480
$By = 360
$Capture = True
$Sequence = True
While 1
$msg = TrayGetMsg()
Select
  Case $msg = $radio1
   TrayItemSetState ($radio1, 1)
   $FullCap = True
   $TightCap = False
   $Sequence = False
  Case $msg = $radio2
   TrayItemSetState ($radio2, 1)
   $FullCap = False
   $TightCap = True
   $Sequence = False
  Case $msg = $radio3
   TrayItemSetState ($radio3, 1)
   $FullCap = True
   $TightCap = True
   $Sequence = False
  Case $msg = $radio4
   TrayItemSetState ($radio4, 1)
   $FullCap = True
   $TightCap = True
   $Sequence = True
  Case $msg = $radio4
   $Ax = 120
   $Ay = 90
   $Bx = 240
   $By = 180
   TrayItemSetState ($radio4, 1)
  Case $msg = $radio5
   $Ax = 240
   $Ay = 180
   $Bx = 480
   $By = 360
   TrayItemSetState ($radio5, 1)
  Case $msg = $radio6
   $Ax = 320
   $Ay = 240
   $Bx = 640
   $By = 480
   TrayItemSetState ($radio6, 1)
  Case $msg = $Pause
   $Capture = Not $Capture
   If $Capture Then
    TrayItemSetState ($Pause, 4)
   Else
    TrayItemSetState ($Pause, 1)
   EndIf
  Case $msg = $Exit
   terminate ()
  EndSelect
If Key_Pressed ("Left") or Key_Pressed ("Right") or $Sequence Then
  If $Capture Then
   _ScreenCapture_SetJPGQuality(80)
   Capture ()
  EndIf
EndIf
;Flow control to prevent frames from capturing too fast.
If $Sequence Then
  Sleep (200)
EndIf
Sleep (50)
WEnd
Func Capture ()
$i = @MSEC
If StringLen ($i) = 2 Then
  $i = "0" & $i
EndIf
$i = @MON & @MDAY & @HOUR & @MIN & @SEC & $i
If $FullCap = True Then
_ScreenCapture_Capture(@MyDocumentsDir & '\Areashots\fullshot' & $i & '.jpg')
EndIf
$pos = MouseGetPos()
$x1 = $pos[0] - $Ax
$y1 = $pos[1] - $Ay
If $x1 < 0 Then
$x1 = 0
$x2 = $Bx
Else
$x2 = $x1 + $Bx
EndIf
If $y1 < 0 Then
$y1 = 0
$y2 = $By
Else
$y2 = $y1 + $By
EndIf
If $TightCap = True Then
_ScreenCapture_Capture(@MyDocumentsDir & '\Areashots\tightshot' & $i & '.jpg',$x1,$y1,$x2,$y2,False)
EndIf
 
EndFunc
Func Key_Pressed ($key)
   Switch StringLower ($key)
Case "Left"
        $iHex = "01"
Case "Right"
   $iHex = "02"
Case "middle"
        $iHex = "04"
Case "ctrl"
        $iHex = "11"
Case "print"
        $iHex = "2C"
Case Else
        Return -1
   EndSwitch
    $aIsPressed = DllCall($hUser32, "int", "GetAsyncKeyState", "int", "0x" & $iHex)
    If @Error Or (BitAND ($aIsPressed[0], 0x8000) <> 0x8000) Then Return 0
    Return 1
EndFunc
Func terminate ()
MsgBox (1,'Area Capture','The program will now exit.')
Exit
EndFunc

It works pretty good for me and my uses, but now I was looking at expanding on this. I would like to take the frame I capture and record directly to avi is this possible? I am not looking at FPS just yet. But anywhere in 1 to 4 FPS is going to be fast enough in most cases.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Look this I am writing a tool with this.

Edited by monoscout999

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0