Wolffe Posted May 10, 2007 Posted May 10, 2007 (edited) Here is a script that I made up to do a screen capture every hour. We were monitoring some equiptment and needed this. It only puts the screenshot into Word. But it does work. Feel free to tinker. I forgot to mention originally that it takes the screenshots from a remote computer. It is handy to monitor server boxes from a distance. CODE ;~ To run this script you will need to have the remote connection window open on your computer. At this point it should take a screen capture every hour ;~ and save it to a Word document. You can change the interval and the IP address using the GUI. #include <GuiConstants.au3> Global $Paused Call ("HKeys") AutoItSetOption ("WinTitleMatchMode",2) $info = 0 GuiCreate("Screen Capture", 315, 105,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $Input_1 = GuiCtrlCreateInput("", 240, 15, 25, 20) $Input_2 = GuiCtrlCreateInput("", 240, 40, 60, 20) $Label_1 = GuiCtrlCreateLabel("Input number of hours between captures", 20, 20, 210, 20) $Label_2 = GuiCtrlCreateLabel("Input IP address of remote connect window", 20, 40, 210, 20) $Button_1 = GUICtrlCreateButton("Ok", 15, 70) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $Button_1 $hours = GUICtrlRead($Input_1) $IP = GUICtrlRead($Input_2) ExitLoop Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd While $info <= $hours Call ("Screencapture") $info = $info + 1 WEnd Func Screencapture() GuiSetState(@SW_HIDE) Mousemove(650,650) WinActivate($IP & " - Remote Desktop") WinWaitActive($IP & " - Remote Desktop") Send("{printscreen}") WinMinimizeAll() Run("cmd /c start winword.exe","",@SW_HIDE) Send("{enter}") ProcessWait("Winword.exe") Send("^v") Sleep(1000) Send("^s") WinWaitActive("Save As") Send(@hour & @min) Send("{enter}") WinClose("Microsoft Word") Sleep(3600000) EndFunc Func HKeys() HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc I added a GUI that allows you to change the time interval without going in to the code. As well it allows you to input the IP address of the remote computer. Like I said. It is handy for me. hopefully someone else will find it so as well. Any comments? suggestions? requests? Anything? EDIT: Modified the script slightly to hide the GUI while the script runs and after you have input the information. Edited May 10, 2007 by Wolffe
Wolffe Posted May 10, 2007 Author Posted May 10, 2007 50 Views and no comments? Anyone have anything to say? Anything?
Gestalt Posted May 10, 2007 Posted May 10, 2007 50 Views and no comments? Anyone have anything to say? Anything?Comment: Change your title to something more descriptive. I think most viewers looked at it just to see what "Well, it's not much" was referring to. By changing the title, you will attract only those who find interest in the script you have written.As for me, I do not have a use for a remote screen shot program at the moment. However, thank you for posting this because I may have a use for it in the future.
James Posted May 10, 2007 Posted May 10, 2007 You can't change the tiltle of your topics I dont think I find it useful, but its a nice piece of code there. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Wolffe Posted May 10, 2007 Author Posted May 10, 2007 Apparently you can change the title of your topics. And thanks to both of you.
Toady Posted May 10, 2007 Posted May 10, 2007 Wow, nice script. Keep up the good work! www.itoady.com A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding
James Posted May 10, 2007 Posted May 10, 2007 My bad, thats just been changed then, because originally you couldn't Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
BillLuvsU Posted May 10, 2007 Posted May 10, 2007 (edited) You can change topic names now? Schweet. Edit: Oh, nice script too Edited May 10, 2007 by fear1313 [center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw
PaulIA Posted May 10, 2007 Posted May 10, 2007 50 Views and no comments? Anyone have anything to say? Anything?How about cleaning up the Screencapture function: #include <A3LScreenCap.au3> Func Screencapture() WinActivate ($IP & " - Remote Desktop") WinWaitActive($IP & " - Remote Desktop") _ScreenCap_CaptureWnd(@Hour & @Min & ".jpg", WinGetHandle($IP & " - Remote Desktop"), False) Sleep(3600000) EndFunc Just captures the window of interest and you can save the screen shot as a BMP, GIF, JPG, PNG or TIF file. Auto3Lib: A library of over 1200 functions for AutoIt
Zedna Posted May 10, 2007 Posted May 10, 2007 How about cleaning up the Screencapture function: #include <A3LScreenCap.au3> Func Screencapture() WinActivate ($IP & " - Remote Desktop") WinWaitActive($IP & " - Remote Desktop") _ScreenCap_CaptureWnd(@Hour & @Min & ".jpg", WinGetHandle($IP & " - Remote Desktop"), False) Sleep(3600000) EndFunc Just captures the window of interest and you can save the screen shot as a BMP, GIF, JPG, PNG or TIF file. Resources UDF ResourcesEx UDF AutoIt Forum Search
Wolffe Posted May 11, 2007 Author Posted May 11, 2007 Hmmm.. I can not seem to make this work. It will open the remote connection screen. But then it just sits there. I have tried looking in the help file and there is no help for this command.. Any idea what I am missing? I copied this in exactly so, I probably needed to add something for my specific program? It would be great if I could get this to work and cut out all those lines in the script. Let me know what I did wrong please. Thanks.
FiNAlzFiNAle Posted May 11, 2007 Posted May 11, 2007 Well, as you can see at the top of the code, you need to include the "A3LScreenCap.au3" file for the script to work. Maybe you can try asking PaulIA for the file? (Since he posted the code for it)
Wolffe Posted May 11, 2007 Author Posted May 11, 2007 I have the file and did include the include. Thanks though.
Zedna Posted May 11, 2007 Posted May 11, 2007 I have the file and did include the include. Thanks though.Then try to catch error (or debug with ConsoleWrite) after each command to see where/what problem is. Resources UDF ResourcesEx UDF AutoIt Forum Search
Wolffe Posted May 11, 2007 Author Posted May 11, 2007 Okay so this is what I get. C:\Documents and Settings\####\Desktop\screentest.au3 (43) : ==> Incorrect number of parameters in function call.: _ScreenCap_CaptureWnd(@Hour & @Min & ".jpg"), WinGetHandle($IP & " - Remote Desktop"), False) ^ ERROR +>AutoIT3.exe ended.rc:0 I am not familiar enough with that function and can't find anything in the help files or here in the forum concerning it... :S
PaulIA Posted May 11, 2007 Posted May 11, 2007 (edited) Okay so this is what I get. C:\Documents and Settings\####\Desktop\screentest.au3 (43) : ==> Incorrect number of parameters in function call.: _ScreenCap_CaptureWnd(@Hour & @Min & ".jpg"), WinGetHandle($IP & " - Remote Desktop"), False) ^ ERROR +>AutoIT3.exe ended.rc:0 I am not familiar enough with that function and can't find anything in the help files or here in the forum concerning it... :SYou copied my script wrong. You've got an extra paren in the line above. It should be like this: _ScreenCap_CaptureWnd(@Hour & @Min & ".jpg", WinGetHandle($IP & " - Remote Desktop"), False) Edited May 11, 2007 by PaulIA Auto3Lib: A library of over 1200 functions for AutoIt
Wolffe Posted May 11, 2007 Author Posted May 11, 2007 Okay, fixed that. I accidentally added that in when I was trying to troubleshoot. But it still just opens the remote connection window and then sits there. This is what I have Func Screencapture() WinActivate ($IP & " - Remote Desktop") WinWaitActive($IP & " - Remote Desktop") _ScreenCap_CaptureWnd(@Hour & @Min & ".jpg", WinGetHandle($IP & " - Remote Desktop"), False) Sleep(3600000) EndFunc
PaulIA Posted May 11, 2007 Posted May 11, 2007 Okay, fixed that. I accidentally added that in when I was trying to troubleshoot. But it still just opens the remote connection window and then sits there.Well, OK, what were you expecting it to do? Did you check to see if it wrote a JPG file to where your script is running? Auto3Lib: A library of over 1200 functions for AutoIt
Wolffe Posted May 11, 2007 Author Posted May 11, 2007 Well, I added the command WinMinimizeAll() so that it looked like Func Screencapture() WinActivate ($IP & " - Remote Desktop") WinWaitActive($IP & " - Remote Desktop") _ScreenCap_CaptureWnd(@Hour & @Min & ".jpg", WinGetHandle($IP & " - Remote Desktop"), False) WinMinimizeAll() Sleep(3600000) EndFunc and nothin happened it would just sit in the remote window. I searched both the remote computer and the local one and neither has a jpg for the screenshot. So, it does not seem to be actually taking a screen shot. At least not that I can find
PaulIA Posted May 11, 2007 Posted May 11, 2007 Well, I added the command WinMinimizeAll() so that it looked like Func Screencapture() WinActivate ($IP & " - Remote Desktop") WinWaitActive($IP & " - Remote Desktop") _ScreenCap_CaptureWnd(@Hour & @Min & ".jpg", WinGetHandle($IP & " - Remote Desktop"), False) WinMinimizeAll() Sleep(3600000)EndFunc and nothin happened it would just sit in the remote window. I searched both the remote computer and the local one and neither has a jpg for the screenshot. So, it does not seem to be actually taking a screen shot. At least not that I can findWell, if it's not getting to the WinMinimizeAll, then it's probably hanging at WinWaitActive. The _ScreenCap call does have any pauses in it at all, so it's not causing your hang problem. Do some debugging like Zedna said. You've got something really simple wrong, but it's not the one line of code you're focused on. Auto3Lib: A library of over 1200 functions for AutoIt
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