Solved

Scroll before taking a screenshot in PHP.

Posted on 2011-09-28
2
367 Views
Last Modified: 2012-05-12
Hello,

I have the following piece of code. Is it possible that before php takes the screenshot of the window, to scroll down 200 pixels? The area I need to take a screenshot from is not visible 100% without scrolling.

Thanks!



$Browser = new COM('InternetExplorer.Application');
$Browserhandle = $Browser->HWND;
$Browser->Visible = true;
$Browser->Fullscreen = true;
$Browser->Navigate('http://www.mysite.com');
while ($Browser->Busy) {
com_message_pump(8000);
}
$img = imagegrabwindow($Browserhandle, 0);
$Browser->Quit();
imagejpeg($img, 'screenshot.jpg', 100);

Open in new window

0
Comment
Question by:infodigger
2 Comments
 
LVL 6

Accepted Solution

by:
neorush earned 500 total points
ID: 36719108
You would need to use WScript.Shell, I have no way of testing this, but it is pretty close...

$shell = new COM("WScript.Shell");
$Browser = new COM('InternetExplorer.Application');
$Browserhandle = $Browser->HWND;
$Browser->Visible = true;
$Browser->Fullscreen = true;
$Browser->Navigate('http://www.mysite.com');
while ($Browser->Busy) {
com_message_pump(8000);
}
// Scroll down, could also try a few {DOWN}{DOWN}{DOWN}{DOWN} "down arrows"
$shell->SendKeys("{PGDN}"); // see http://www.developerfusion.com/article/57/sendkeys-command/
$img = imagegrabwindow($Browserhandle, 0);
$Browser->Quit();
imagejpeg($img, 'screenshot.jpg', 100);

Open in new window

0
 

Author Comment

by:infodigger
ID: 36813617
Hi Neorush,

Is it also possible to make php focus on that Window as well? Because I was able to send the keys but they are sent to the window which is currently open not to the new one.

Thanks!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to use a switch statement with heredoc 11 33
AJAX pass along a variable 3 46
Inserting data into database 10 36
Test if unique ID is in log file 5 22
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question