Jump to content

Need to capture screen while computer locked


Recommended Posts

Hey, first of all thatnks to the members of this forum for helping me out with existing post.

So I need to do a screen capture (specifically an IE window, but whole screen would be better) on a machine while it is locked. I have worked through the other dificulties of scripting for a locked machine, but now I'm stuck. It seems that just using Send("{PRINTSCREEN}") doesn't have any effect (I assume the same for any Send command) ControlSend doesn't seem to work either, probably because the contol I am sending the command to doesn't know what to do with it. I have also tried screen cap functions, such as _ScreenCap in Auto3Lib and these just save an image of a black screen when run on a locked computer.

Has any one run into this, or have any ideas? Unfortunatly using a third party unlocker is not an option (IT doesn't want to install any apps)

Thanks in advance,

Eric

Link to comment
Share on other sites

You may want to give an explanation on the purpose of this. The moderators don't take kindly to covert scripts like this.

If the computer is locked then you should have the ability to unlock it.

So which category does this fall under?

A. You are defending Sparta from the Persion army

B. You are the Greeks sieging the city of Troy

Link to comment
Share on other sites

You may want to give an explanation on the purpose of this. The moderators don't take kindly to covert scripts like this.

If the computer is locked then you should have the ability to unlock it.

So which category does this fall under?

A. You are defending Sparta from the Persion army

B. You are the Greeks sieging the city of Troy

My apologies, I'll clarify. I guess category A is closer, but really more of just a sheepherder checking the herd to make sure no sheep got eaten, while it is still dark outside <_<

First of all this script is only running on one computer, not trying to remote connect or anything. Basically what it is doing is logging into a website (which can be done on any computer on the network) navigating through a few pages and taking a screenshot of a status screen, and saving it. The admin will set it up as a scheduled task to run a few times overnight. Since it is running overnight, the computer will be locked. Also, I don't want to unlock it, just get a screenshot, and save the screenshot locally. I'll include my script here, I don't think it will help, but it should at least show what I am trying to do:

#include<IE.au3>

WinMinimizeAll()
$Pass = "password";password to access webpage
$savePath = "C:\Screenshots\";path that screenshots will be saved to, path must already exist

Local $oIE
    $oIE=_IECreate("https://www.website.com")

    $hIE = _IEPropertyGet($oIE, "hwnd")
    WinSetState($hIE, "", @SW_MAXIMIZE)
    $oForm = _IEFormGetObjByName ($oIE, "Logon_form")
    $oPassword = _IEFormElementGetObjByName ($oForm, "T122")
    $oSignin = _IEFormElementGetObjByName ($oForm, "button22")
    _IEFormElementSetValue ($oPassword, $Pass)
    _IEAction ($oSignin, "click")
    sleep(4500)
    MouseClick("left", 80, 230, 1, 0)
    sleep(3500)
    MouseClick("left", 80, 260, 1, 0)
    sleep(5500)
    MouseClick("left", 240, 310, 1, 0)
    MouseClick("left", 240, 310, 1, 0)
    sleep(4000)
;take the screenshot
    Send("{PRINTSCREEN}")
;sleep(1000)
    WinSetState ($oIE, "", @SW_MINIMIZE )
    Run("C:\Program Files\Windows NT\Accessories\wordpad.exe", "",@SW_MAXIMIZE)
    sleep(2000)
    ControlFocus("Document - WordPad","","")
    ControlClick("Document - WordPad","","59648")
    sleep(3000)
    ControlFocus("Document - WordPad","","")
    ControlSend("Document - WordPad","","","{CTRLDOWN}v{CTRLUP}")
    sleep(2000)
    ControlSend("Document - WordPad","","","{ALTDOWN}fa{ALTUP}")
    sleep(1500)
    ControlSend("Document - WordPad","","","{ALTDOWN}n{ALTUP}")

    $Time = @MON & "-" & @MDAY & "-" & @YEAR & "_" & @HOUR & "-" & @MIN
    $sFileName = $savePath & $Time
    ControlFocus("Save As","",1148)
    ControlSetText("Save As","",1148,$sFileName)
    sleep(1500)
    ControlFocus("Save As","","")
    ControlSend("Save As","","","{ALTDOWN}s{ALTUP}")
    Sleep(1500)
    $sWindowName = $Time & " - WordPad"
    $sWindowName2 = $Time & ".rtf" & " - WordPad"
;MsgBox(0,"name",$sWindowName)
    WinClose($sWindowName)
    WinClose($sWindowName2)

    _IEQuit ($oIE)
Link to comment
Share on other sites

Also, I can unlock the computer if need be, the username and password are available to me, it would just need to be done from the script. So if there is a way to do this, that would be great, its just that from looking through this forum I came to the conclusion that this was not possible. It would be great if I was wrong though.

Eric

Link to comment
Share on other sites

not too sure about your problem but here is something to improve your code

$savePath = "C:\Screenshots\";path doesn't have to exist!
IF DirGetSize($SavePath) = -1 then DirCreate($SavePath)
Yeah, it was only going to go to one path, and I was to lazy to create it. Thanks though, this will make it a bit more robust (no more "forgot to create the #$@#$@# directory" for me) <_<
Link to comment
Share on other sites

Yeah, it was only going to go to one path, and I was to lazy to create it. Thanks though, this will make it a bit more robust (no more "forgot to create the #$@#$@# directory" for me) <_<

Well just glad i could (sorta) help you out...

[center][/center]

Link to comment
Share on other sites

by the way if you can clearly describe step by step whats supposed to happen then I'd bet you could finish this, i could help you. this is NOT impossible!

Alright, here is the deal, and something just changed that may make things easier.

Overall what I am trying to do, is create a script that will be run automatically, by windows scheduler, a few times over night. The problem is that the machine it is running on must be locked. As I said earlier if a script can unlock a machine without any other applications installed that would be fine. The purpose is to get some information from a webpage and save it. Initially I was doing this by logging into the page taking a screenshot and saving that. I got everything working locked except for the actual screen capture.

Now, we figured out that the page has an export function that I can use. So I am going to bypass the whole screenshot thing, which should make it easier. In fact, I have it working properly on my machine, even if it is locked (I'll put the code here, though it is not much different from above.) And when we put it on the server that it is eventually going to run on it works fine as long as we have a remote connection running. However, once we schedule it and disconnect it no longer works. It seems that the clicking is off. Unfortunatly, coordinate based clicking is the only way I have been able to do it since the page is in Javascript and I can't figure out how to use the normal IE interaction commands. Like I said though, it works fine on my machine even locked.

So what I think is needed is just to get the clicks adjusted to the right place. However, I really don't know how to do that, since it is only when locked that it doesn't work, and I can't see where it is or isn't clicking.

Any thoughts would be appriciated, if I left out something important just let me know.

Thanks,

Eric

#include<IE.au3>
AutoItSetOption ( "SendKeyDownDelay" , 400)

WinMinimizeAll()
$Pass = "password" ;password to access page
If DirGetSize($savePath) = -1 then DirCreate($savePath)
$savePath = "C:\Screenshots\" ;path that screenshots will be saved to, path will be created if it doesn't already exist

Local $oIE
    $oIE=_IECreate("http://www.webpage.com")
    $hIE = _IEPropertyGet($oIE, "hwnd")
    WinSetState($hIE, "", @SW_MAXIMIZE)
    $oForm = _IEFormGetObjByName ($oIE, "Logon_form")
    $oPassword = _IEFormElementGetObjByName ($oForm, "T122")
    $oSignin = _IEFormElementGetObjByName ($oForm, "button22")
    _IEFormElementSetValue ($oPassword, $Pass)
    _IEAction ($oSignin, "click")
    sleep(5000)

;server
    sleep(4500)
    MouseClick("left", 80, 230, 1, 0)
    sleep(3500)
    MouseClick("left", 80, 260, 1, 0)
    sleep(5500)
    MouseClick("left", 240, 310, 1, 0)
    MouseClick("left", 240, 310, 1, 0)
    sleep(4000)
    ;click the export button
    MouseClick("left", 670, 290,1,0)
    WinSetState ($oIE, "", @SW_MINIMIZE )
    WinWait("File Download - Security Warning")
    sleep(500)
    WinActivate ("File Download - Security Warning")
    ControlFocus("File Download - Security Warning","", "")
    ControlSend("File Download - Security Warning","", "", "{ALTDOWN}s{ALTUP}")
    sleep(1000)
    $Time = @MON & "-" & @MDAY & "-" & @YEAR & "_" & @HOUR & "-" & @MIN
    $sFileName = $savePath & $Time
    ControlFocus("Save As","",1148)
    ControlSetText("Save As","",1148,$sFileName)
    sleep(1500)
    ControlFocus("Save As","","")
    ControlSend("Save As","","","{ALTDOWN}s{ALTUP}")
    Sleep(1500)
    ControlFocus("Download complete","", 2)
    ControlClick("Download complete","", 2)

    _IEQuit ($oIE)
Link to comment
Share on other sites

I'll test that source when i get home, maybe your two computers have diff. resloutions or somthing?? But I now can understand your purpose and goal much better... I see what your trying to do, so if you can send data would a list of all exe's that are runnig be good? Or a list of all windows? That should be much eaiser, if it must be a screenshot though thats fine we can try to make this work... I'm sure theres a way...

[center][/center]

Link to comment
Share on other sites

I'll test that source when i get home, maybe your two computers have diff. resloutions or somthing?? But I now can understand your purpose and goal much better... I see what your trying to do, so if you can send data would a list of all exe's that are runnig be good? Or a list of all windows? That should be much eaiser, if it must be a screenshot though thats fine we can try to make this work... I'm sure theres a way...

There are no other windows open. It would be interesting to get a screenshot working with the computer locked, but I have kind of moved away from that and decided to just use the export function of the website. There is another interesting thing about screenshotting with the machine locked, if you try to paste anything into MS Paint, on a locked computer Paint crashes, I found that funny.

Edited by echiappone
Link to comment
Share on other sites

There is another interesting thing about screenshotting with the machine locked, if you try to paste anything into MS Paint, on a locked computer Paint crashes, I found that funny.

I wondered why you were using WordPad.

What about using wget to get the web page and then you can view it on the machine where you would have been viewing the screenshots? Or are the screenshots absolutely necessary?

Or maybe PDFCreator would be useful in this endeavor? That way you could open IE and "print" a copy of the web page?

Link to comment
Share on other sites

I wondered why you were using WordPad.

What about using wget to get the web page and then you can view it on the machine where you would have been viewing the screenshots? Or are the screenshots absolutely necessary?

Or maybe PDFCreator would be useful in this endeavor? That way you could open IE and "print" a copy of the web page?

Yeah, it was a strange workaround, just because wordpad didn't crash like paint did, not a good permanent solution.

As far as the screenshots go, yes screenshots, or some sort of record is needed. The export function that I mentioned earlier would be fine too, but some file showing the info on the page is needed.

The PDFCreator might not be a bad idea, IT doesn't want any additional apps installed, but possibly some kind of print to file might work, thanks for that idea I will look into it.

Howver, the problem still primarily seems to be just navigating the web page. It doesn't seem to be getting to the needed page (it works on my computer, but not the server it needs to run on) So I think that the clicks are off, but I don't really know how to adjust it, because I can't see it clicking while it is locked.

Thanks,

Eric

Link to comment
Share on other sites

Actually, I was thinking that some of my problems may be solved by using the IE UDF rather then clicks. This which works fine in the first part of my code, but that is for the login page which is simple HTML. The problem is that the next couple of clicks are on a page the is in Javascript and I can't find any form/object IDs or names that I can use. However, I have not really used the IE stuff. If there is a good way of working with Javascript pages that would probably be helpful.

Thanks,

Eric

Link to comment
Share on other sites

OK, here is an update on the situation:

I think I have everything worked out except the actual navigation of the webpage. The first page is a logon page that I have working. I was able to use the IE UDF to put in a password and click a button, it isn't working now for some reason, possibly because I have changed to Windows Server 2003? However, I am able to send some keystrokes to the window and it works, even locked.

That takes us to the problem. After logging in a few clicks are needed. I can't seem to get this worked out. Just plain coordinate clicking works fine, until I lock the computer, then it does nothing. I can't use ControlClick() because there is no control to click. And I can't seem to get the IE UDF commands to work either.

On the bright side, once those clicks are done, the rest is working fine ( I think).

So, if you have any thoughts on navigating through a web page on a locked computer, I would appricate your throughts,

Eric

P.S. Here is my most recent code:

#include<IE.au3>
AutoItSetOption ( "SendKeyDownDelay" , 400)
WinMinimizeAll()
$Pass = "password" ;password to access page

$savePath = "C:\AVScreenshots\" ;path that export will be saved to, path will be created if it doesn't already exist
If DirGetSize($savePath) = -1 then DirCreate($savePath)

    Local $oIE
    $oIE=_IECreate("www.webpage.com",0,1,0)
    sleep(1000) 
        ControlClick("Security Alert", "&Yes",1)
;maximize IE
    $hIE = _IEPropertyGet($oIE, "hwnd")
    WinSetState($hIE, "", @SW_MAXIMIZE)
    
#comments-start
;Logon
    $oForm = _IEFormGetObjByName ($oIE, "Logon_form")
    $oPassword = _IEFormElementGetObjByName ($oForm, "T122")
    $oSignin = _IEFormElementGetObjByName ($oForm, "button22")
    _IEFormElementSetValue ($oPassword, $Pass)
    _IEAction ($oSignin, "click")
#comments-end
    _IELoadWait ($oIE)
    sleep(500)
    ;Send("{LEFT}")
    ;send("{Enter}")
    ControlSend("Trend Micro OfficeScan - Microsoft Internet Explorer","","","password")
    ControlSend("Trend Micro OfficeScan - Microsoft Internet Explorer","","","{Enter}")
    _IELoadWait ($oIE)


; Navigate to the Client Management page
    MouseClick("left", 80, 250, 1, 0)
    sleep(2000)
    MouseClick("left", 80, 270, 1, 0)
    sleep(6000)
    MouseClick("left", 240, 330, 1, 0)
    MouseClick("left", 240, 330, 1, 0)
    sleep(2500)

;click the export button
    MouseClick("left", 670, 280, 1, 0)

    
; export 

    sleep(1000)
    $Time = @MON & "-" & @MDAY & "-" & @YEAR & "_" & @HOUR & "-" & @MIN
    $sFileName = $savePath & $Time
    ControlFocus("Save As","",1148)
    ControlClick("Save As","",1148)
    ControlSetText("Save As","",1148,$sFileName)
    sleep(1500)
    ControlFocus("Save As","&Save","")
    ControlSend("Save As","&Save","","{ALTDOWN}s{ALTUP}")
    Sleep(1500)
    ControlFocus("Download complete","", 2)
    ControlClick("Download complete","", 2)
    
    _IEQuit ($oIE)
Link to comment
Share on other sites

The PDFCreator might not be a bad idea, IT doesn't want any additional apps installed, but possibly some kind of print to file might work, thanks for that idea I will look into it.

Well, if IT has certain requirements, that makes sense. If they will allow it, note that it doesn't just print to PDF. It can print to PNG, JPG, BMP, et al.

Although, I wonder why AutoIt doesn't have access to the MSPaint/PrintScreen clipboard like it does to the text clipboard? Is the PrintScreen clipboard a hack?

Link to comment
Share on other sites

Well I finally got the website navigation worked out. Using the DebugBar tool, I was able to finally figure out the names of the frames and buttons that I needed to make the IE UDFs work. Hurrah. Now there is a security window opening on the computer my script will run on that I didn't see on my computer, but hopefully it will be fairly easy to work out.

Eric

Link to comment
Share on other sites

Well I finally got the website navigation worked out. Using the DebugBar tool, I was able to finally figure out the names of the frames and buttons that I needed to make the IE UDFs work. Hurrah. Now there is a security window opening on the computer my script will run on that I didn't see on my computer, but hopefully it will be fairly easy to work out.

Eric

Well, it turns out that I'm a liar. That last "easy" window has become my nemisis. For some reason I cannot click on the "Save" button. This is the window that opens when you are downloading something that has two options "Save" and "Cancel":

post-28876-1195006202_thumb.png

I have tried the following things to no avail. Each one works when the computer is unlocked, but do nothing when the computer is unlocked:

WinWait("File Download - Security Warning")
    sleep(500)
    WinActivate ("File Download - Security Warning")
    ControlFocus("File Download - Security Warning","", 4424)
    ControlClick("File Download - Security Warning","", 4424)
    ControlFocus("File Download - Security Warning","","[CLASS:Button; TEXT:&Save; INSTANCE:2]")
    ControlClick("File Download - Security Warning","","[CLASS:Button; TEXT:&Save; INSTANCE:2]")
    ControlSend("File Download - Security Warning","", "", "{ALTDOWN}s{ALTUP}")
    ControlSend("File Download - Security Warning","", "", "{TAB}")
    ControlSend("File Download - Security Warning","", "", "{TAB}")
    ControlSend("File Download - Security Warning","", "", "{ENTER}")
    ControlSend("File Download - Security Warning","", "", "{SPACE}")

So I am really hoping someone has run into this before, because I am out of ideas.

Thanks,

Eric

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...