Elephant007 Posted September 17, 2013 Share Posted September 17, 2013 this little script will take a screenshot anytime the main screen changes i would like some help to have the files save in sequential order instead of relying on a combination of date and time. e.g. image00001.png, image00002.png etc Also, any idea how to uses these files to make a mp4 (or other format) after the files are saved? As always I'm up for any improvements! Thank you in advance #include <ScreenCapture.au3> Local $var = FileSelectFolder ("Select Where To Save", ".\" , 0, @DesktopDir) If @error Then MsgBox(4096,"", "Save Cancelled") Exit Else DirCreate ( $var & "\" & @MON & "-" & @MDAY & "-" & @YEAR ) MsgBox(4096,"", "Save Location: " & $var & "\" & @MON & "-" & @MDAY & "-" & @YEAR) EndIf HotKeySet("{Esc}", "Quit" ) Call("StartCapture") Func StartCapture() While 1 $a = WinGetTitle("") Do $b = WinGetTitle("") Until $a <> $b Sleep (1000) _ScreenCapture_Capture ( $var & "\" & @MON & "-" & @MDAY & "-" & @YEAR & "\" & @HOUR & @MIN & @SEC & ".png" ) WEnd EndFunc Func Quit () Exit EndFunc Link to comment Share on other sites More sharing options...
BrewManNH Posted September 17, 2013 Share Posted September 17, 2013 For the file name you can use something like this. $Count = 1 _ScreenCapture_Capture($var & "\" & "image" & StringFormat("%05s", $Count) & ".png") $Count += 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Elephant007 Posted September 17, 2013 Author Share Posted September 17, 2013 Thank you for the quick reply, I did as you suggested and now the file doesn't save in the selected directory which real isn't a deal breaker for me The file creates as expected, except it overwrites itself so I only end up with one file total named image000001.PNG I tried tweaking on your suggestions with no success Link to comment Share on other sites More sharing options...
kylomas Posted September 17, 2013 Share Posted September 17, 2013 Elephant007, This works for me (captures a screen image whenever the active window title changes). See comments in code... #include <ScreenCapture.au3> Local $var = FileSelectFolder ("Select Where To Save", ".\" , 0, @DesktopDir) If @error Then MsgBox(4096,"", "Save Cancelled") Exit Else DirCreate ( $var & "\" & @MON & "-" & @MDAY & "-" & @YEAR ) MsgBox(4096,"", "Save Location: " & $var & "\" & @MON & "-" & @MDAY & "-" & @YEAR & '\') ; <---- added dir '\' EndIf HotKeySet("{Esc}", "Quit" ) Call("StartCapture") Func StartCapture() $Count = 1 ; <---- before loop, otherwise it gets reset every time to 1 While 1 $a = WinGetTitle("[active]") ; <---- get currently active window Do $b = WinGetTitle("[active]") ; <---- get currently active window sleep(250) Until $a <> $b _ScreenCapture_Capture($var & "\" & @MON & "-" & @MDAY & "-" & @YEAR & '\' & "image" & StringFormat("%05s", $Count) & ".png") ; <--- fully qualified path $Count += 1 ;_ScreenCapture_Capture ( $var & "\" & @MON & "-" & @MDAY & "-" & @YEAR & "\" & @HOUR & @MIN & @SEC & ".png" ) WEnd EndFunc Func Quit () Exit EndFunc kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Elephant007 Posted September 17, 2013 Author Share Posted September 17, 2013 Elephant007, This works for me (captures a screen image whenever the active window title changes). See comments in code... #include <ScreenCapture.au3> Local $var = FileSelectFolder ("Select Where To Save", ".\" , 0, @DesktopDir) If @error Then MsgBox(4096,"", "Save Cancelled") Exit Else DirCreate ( $var & "\" & @MON & "-" & @MDAY & "-" & @YEAR ) MsgBox(4096,"", "Save Location: " & $var & "\" & @MON & "-" & @MDAY & "-" & @YEAR & '\') ; <---- added dir '\' EndIf HotKeySet("{Esc}", "Quit" ) Call("StartCapture") Func StartCapture() $Count = 1 ; <---- before loop, otherwise it gets reset every time to 1 While 1 $a = WinGetTitle("[active]") ; <---- get currently active window Do $b = WinGetTitle("[active]") ; <---- get currently active window sleep(250) Until $a <> $b _ScreenCapture_Capture($var & "\" & @MON & "-" & @MDAY & "-" & @YEAR & '\' & "image" & StringFormat("%05s", $Count) & ".png") ; <--- fully qualified path $Count += 1 ;_ScreenCapture_Capture ( $var & "\" & @MON & "-" & @MDAY & "-" & @YEAR & "\" & @HOUR & @MIN & @SEC & ".png" ) WEnd EndFunc Func Quit () Exit EndFunc kylomas Wow! Thank you so much, I appreciate the comments too. This helps me learn. I can now figure out the rest on my own... perhaps I will change it up a little bit so the user can name their own folder just in case they want to do more than one recording the same day.. Again I think you both Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now