Recommended Posts

Everyday I (and my colleagues at work) need to take some screenshots from a web-page. These screenshots are used to compile a report. Normally, I (and others) used to log in into the website and took screenshots of desired graphics and tables. This is tediuos and time consuming. To easy this task I made a script using autoit that basically logs into the website (user and password) and using some clicks, stroke send, coordinates, it is able to generate the graphics and save them to some folders into our network (this script saves arouund 50 pics. It works like a sharm.

In order to make things easier, I tried to schedule this script (compiled to a Screnpics.exe file) using task scheduler from windows. We already use this (task scheduler) to run some vbs scripts, some vba excel scripts and so on. The computer used for this tasks is a windows 7 desktop computer. Due to security policies, the computer locks after some time. All this tasks run in the locked computer.

My script screenpics.exe runs also from this locked computer. When the computer is unlocked, it does everything as expected. But, when it is locked, all the "pics" are BLACK. As I understand, it runs ok, but, as the "windows" are innactive, it prints what it "sees": a black rectangular.

Some details: The web-page with hold the information I need, it only works in Firefox and, because of this it couldn`t be managed by vba or some "getobject" like commands. In fact, it has some flash things that make it impossible to control programatically. So my script is based on mouse move to coordinates, mouse click, screen capture and so one.

So, I read many posts trying to figure out a way to overcome this, but... nothing came to mind. My first idea was try to unlock windows. Theses lead me to some posts with no solution. This is worse because I'm not a computer admin, so procedures that need to replace/change the register are not an option.

If someone has any idea, I'll be gratefull.

Share this post

Link to post

Share on other sites

As I've understand with your issue is that when the computer exceeds the time limit, it will automatically locked the computer and your program won't work doing some screen capture.... well, as suggested with some other language, you can use the Anti Locking System coded in VB script and possible for Autoit codes, however, this system will unfortunately will not be locked unless the user will locked the computer. If you want it that way, then maybe I can help you.

Share this post

Link to post

Share on other sites

Hi, when the computer is locked, it runs ok (I scheduled it through task scheduler for 7:30 AM), but the snapshots are "black pics/black rectangles".

Using codes to avoid computer locking is not an option, since this computer will became available to everyone (other users), and they could, using my user and password (because the computer will be open) acess some restricted folders/programs/information.

Cause of this, I need to unlock the computer and run and lock again, OR, correct the issue of saving "black snapshots".

Share this post

Link to post

Share on other sites

... to grab data from web tables there are more appropriate ways than capturing screens, but that's another story.
however, keeping the topic on the capture of the FireFox screenshots, you could try the following way:

Share this post

Link to post

Share on other sites

copy the following script (3 functions) and paste it to the bottom of your already working script (ensure that #include <ScreenCapture.au3> is present at the top of your script)

to capture the screenshot of the FireFox window replace the line in your script where you call _ScreenCapture_Capture ( $networkSharePath & "\peo_craq_rpbc_top10_alarmop.png", 282, 175, 1062, 640) with the following line instead: _CaptureFireFox_Screen($sFilename) wher $sFilename contains the path and filename of the picture you wish to save. This should save a picture of the FireFox window on the path and with the name specified in the $sFilename parameter even if the screen is locked (it works on my system).

Share this post

Link to post

Share on other sites

Are you sure that the issue is because the computer is locked? I just ran a test on a Windows 7 box and my script successfully captured the specified window while the computer was sitting at the login screen.

I think your issue may be that a screen screen saver is running, your power settings are set to power down the monitor after a certain amount of idle time, or both, Can you check to see if you have a screen saver enabled and/or whether your power settings are set to shut off the monitor? If the power settings are shutting off the monitor, I have a solution for that.

Share this post

Link to post

Share on other sites

I recently had the same issue where screen captures of web pages would render as blank/black pages when using _ScreenCapture_CaptureWnd(). What fixed the issue for me was disabling graphics acceleration in the browser's settings.

Sign in

Similar Content

Hay guys
Just had an idea and wanted to know where to start. I want to download a screenshot of a website automatically into a .png .jpg ect format so I can then set it as my desktop background.
This might be for for news: When the latest news is added to a website a screenshot of that website is saved and added to my desktop background.
I have tried using website that already do the screenshot but you have to open the website and click the button for it to generate one and thus InetGet does not help.
Any Ideas?

Has anybody else noticed that Windows 7 reacts ignorantly when you use the Windows key + arrow key shortcuts on a GUI with GUIEventMode set to 1? I discovered this recently when I was working on an app where I wanted complete control over the maximize/minimize buttons.
Just give it a spin:
#include <GUIConstants.au3>
Opt('GUIEventOptions', 1)
$hGUI = GUICreate('', 300, 200, Default, Default, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX))
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_MAXIMIZE
ToolTip('Maximized')
Case $GUI_EVENT_MINIMIZE
ToolTip('Minimized')
Case $GUI_EVENT_RESTORE
ToolTip('Restored')
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Run that, then hit Win+Up or Win+Down. None of those events get triggered, and it still maximizes/minimizes. Although I can't get it to restore down from a maximize unless the window is also resizable ($WS_THICKFRAME in the style).
Is there a way to stop Windows from doing what it wants or is the only option to check with WinGetState() and then change it back?

Windows 10 seems to respect my settings, and I don't have any other versions to test on.

I have a script that just adds some keyboard shortcuts for things like displaying the current song and artist, moving the window to the side so it won't pop up in my way, and play/pause, next song, previous song (these are the only 3 to still work since they don't need the window handle.)
In some update recently, Spotify's window class swapped from "[CLASS:SpotifyMainWindow]" to "[CLASS:Chrome_WidgetWin_0]". Using the new class in my controls doesn't seem to work, I've tried getting the window handle from the process handle (_GetHwndFromPID($PID)) but that seems to fail as well.
Does anybody have some idea of a way I could get this script working again?

edit: seems like discord has the same window class name, so could be some issue with this? Still not sure of a way to solve the issue though, I added a function to get the handle of the active window and can just use that now, but it was able to find it on its own before on spotify startup or script startup which would be preferred.