Jump to content

Screenshot your remote PC


Wolffe
 Share

Recommended Posts

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. :D 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 by Wolffe
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

You can change topic names now? Schweet.

Edit: Oh, nice script too :)

Edited by fear1313

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

:):D
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

You 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 by PaulIA
Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Well, 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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...