Elephant007 Posted October 21, 2010 Share Posted October 21, 2010 (edited) Below is code I was able to find here and tweak to my liking, almostThe part I would like to know how to change is instead of this taking a screenshot every 10 seconds I would like for it to take a screenshot anytime a new window appears OR anytime the desktop has some sort of GUI change.I tried adding WinWait ("","")This just took more rapid screenshots. The purpose of this code is to monitor the installation of a very large program. I don't want have to have to sit and wait for each window to popup and record because I plan on making the entire installation silent using AutoIt scripting #include <ScreenCapture.au3> HotKeySet("{Esc}", "Quit") Call("StartCapture") Func StartCapture() While 1 Sleep(10000) _ScreenCapture_Capture ("C:\" & @HOUR & @MIN & @SEC & ".jpeg") Wend EndFunc Func Quit () Exit EndFuncWith bogQ's help I was able to find a solution for thisyou can find the solution here Solution In Thread Edited October 21, 2010 by Elephant007 Link to comment Share on other sites More sharing options...
bogQ Posted October 21, 2010 Share Posted October 21, 2010 i don't think that i completely understand what are you asking If you trying to get new active win you can try like this While 1 $a = WinGetTitle("") Do $b = WinGetTitle("") Until $a <> $b MsgBox(0,"","something happend") WEnd If you try to get new win that was not there before than i think you shud use WinList() to get it and then compare it to new list to get new win TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
Elephant007 Posted October 21, 2010 Author Share Posted October 21, 2010 thank you for your reply. In it's basic form this is what I want to accomplish Start my code and let it run in a loop Anytime a new window opens on my computers, I want the code to take a screen shot and save it as a JPEG ( using @hour & @min & @sec & ".jpeg" for the file name) Currently my code takes a screen shot every 10 seconds. I want to change it from 10 seconds to when a (non-existing) window appears. I won't know the name of any of the windows that will appear Link to comment Share on other sites More sharing options...
bogQ Posted October 21, 2010 Share Posted October 21, 2010 (edited) This should work if im not wrong, it should react on new wins with diffrent title, if they are with the same title try to change _ArraySearch($var1, $var2[$x][0], 0, 0, 0, 1) to _ArraySearch($var1, $var2[$x][1], 0, 0, 0, 1) and see if its working after change #include <Array.au3> $var1 = WinList() While 1 $var2 = WinList() For $x = 1 To $var2[0][0] $iIndex = _ArraySearch($var1, $var2[$x][0], 0, 0, 0, 1) If @error And $var2[$x][0] <> "" And IsVisible($var2[$x][1])Then MsgBox(0, "New Win", WinGetTitle($var2[$x][1])) $var1 = WinList() EndIf Next If $var2[0][0] <> $var1[0][0] Then $var1 = WinList() EndIf WEnd Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc Edit: note that this script is eating up CPU Edited October 21, 2010 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
Elephant007 Posted October 21, 2010 Author Share Posted October 21, 2010 (edited) Thanks again for your speedy and excellent help!The first code you provided me did the trick, I added to my existing code and it's about 3/4th complete... the only thing I feel it's lacking is adding a slight delay before the screen shot is taken... prehaps just one or two seconds..If you're able to inform me how to add the delay, I can tweak it to my liking, here is my new code#include <ScreenCapture.au3> HotKeySet("{Esc}", "Quit") Call("StartCapture") Func StartCapture() While 1 $a = WinGetTitle("") Do $b = WinGetTitle("") Until $a <> $b _ScreenCapture_Capture ("C:\" & @HOUR & @MIN & @SEC & ".jpeg") WEnd EndFunc Func Quit () Exit EndFuncWhen run, the script will capture the desktop screen when new windows appears. It saves the image to the C drive with the HOUR MINUTE SECOND .JPEGyou can press the ESC key to exit the scriptAgain, thank you for your excellent help... Just need to just figure out how to delay the _ScreenCapture_CaptureThank yoU!@ Edited October 21, 2010 by Elephant007 Link to comment Share on other sites More sharing options...
bogQ Posted October 21, 2010 Share Posted October 21, 2010 Sleep(1000) that 1000 is 1 second TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
Elephant007 Posted October 21, 2010 Author Share Posted October 21, 2010 (edited) Sleep(1000) that 1000 is 1 second Where do I put that code? Right after Until $a <> $b? Until $a <> $b Sleep (1000) Edited October 21, 2010 by Elephant007 Link to comment Share on other sites More sharing options...
bogQ Posted October 21, 2010 Share Posted October 21, 2010 yes TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
Elephant007 Posted October 21, 2010 Author Share Posted October 21, 2010 thanks! With you guidance I was able to complete this code!!!I will post it here and in the first of this thread tooQ: What will this code do?A: Oa message box with some info, click OK to start the program, CANCEL to exit from starting the program. Once you click OK a directory will be created on your C drive called "ScreenCaptures" with a subdirecty MONTH-DAY-YEAR.Any changes made on your desktop will be captured and saved as a JPEG in the directory created "C:\ScreenCaptures\MONTH-DAY-YEAR"The jpeg's are saved as HOUR.MINUTE.SECOND.JPEG, this way they will be stored sequencially.Feel free to use and change as needed#include <ScreenCapture.au3> $MsgBox01 = MsgBox ( 1, "ScreenCaptures", "Starting ScreenCapture" & @CRLF & "Press ESC to Quit ScreenCapture" & @CRLF & "Images saved to C:\ScreenCaptures\" & @MON & "-" & @MDAY & "-" & @YEAR & @CRLF & "Click cancel to not run ScreenCapture" ) If $MsgBox01 = 2 Then Exit DirCreate ( "C:\ScreenCaptures\" & @MON & "-" & @MDAY & "-" & @YEAR ) HotKeySet("{Esc}", "Quit") Call("StartCapture") Func StartCapture() While 1 $a = WinGetTitle("") Do $b = WinGetTitle("") Until $a <> $b Sleep (1000) _ScreenCapture_Capture ( "C:\ScreenCaptures\" & @MON & "-" & @MDAY & "-" & @YEAR & "\" & @HOUR & @MIN & @SEC & ".jpeg" ) ; _ScreenCapture_Capture ("C:\ScreenCaptures\" & @HOUR & @MIN & @SEC & ".jpeg") WEnd EndFunc Func Quit () Run ( "Explorer.exe " & "C:\ScreenCaptures" ) Exit EndFunc 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