note 50587 added to class.com
| From: | csaba at alum dot mit dot edu | Date: | Fri, 04 Mar 2005 01:21:51 +0000 |
| Subject: | note 50587 added to class.com | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-85901@lists.php.net to get a copy of this message | ||
Getting IE to the foreground
If you are using a command line (CLI) version of PHP on a Win32 platform (e.g. XP Pro, SP2), you
might want to have output directed to IE (perhaps you'll want to work with the output there)
when Popup does not suffice (see my earlier post, below).
It's easy enough to get an instance of IE using $ie = new
COM("InternetExplorer.Application");. The problem is, you don't necessarily see it
in the foreground (especially if you already have one open) and who wants to waste keystrokes
getting to it? The code below has been working for me (If you want to do other adjustments (e.g.
$ie->Document->ParentWindow->resizeTo(800,500); or $ie->Document->Body->bgColor =
"yellow";), doing them before the $ie->Visible = true; line will avoid screen
distractions):
<?php
function newIEtoForeground($title, $evtPrefix="") {
// brings new instance of IE to foreground with title $title
if (!$extPrefix) $ie = new COM("InternetExplorer.Application");
else $ie = new COM("InternetExplorer.Application", $evtPrefix);
$ie->Navigate2("about:blank");
$oWSH = new COM("WScript.Shell");
while ($ie->ReadyState!=4) usleep(10000);
$ie->Document->Title = ($tmpTitle = mt_rand()); //unique title
$ie->Visible = true;
while (!$oWSH->AppActivate("$tmpTitle - M")) usleep(10000);
$ie->Document->Title = $title;
$ie->Document->ParentWindow->opener="me"; // allows self.close()
return $ie;
}
?>
Csaba Gabor from Vienna
----
Manual Page -- http://www.php.net/manual/en/class.com.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50587
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50587&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50587&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50587&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50587&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50587&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50587&report=yes
Search -- http://master.php.net/manage/user-notes.php