?
Solved

Scroll before taking a screenshot in PHP.

Posted on 2011-09-28
2
Medium Priority
?
388 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
neorush earned 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.
Suggested Courses

777 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