note 83698 added to class.com

From: Date: Sun, 08 Jun 2008 10:19:10 +0000
Subject: note 83698 added to class.com
Groups: php.notes 
Request: Send a blank email to php-notes+get-140229@lists.php.net to get a copy of this message
Using the DynamicWrapper from http://freenet-homepage.de/gborn/WSHBazaar/WSHDynaCall.htm and after registering it via "regsvr32 dynwrap.dll", you can easily set output colors to make colorful CLI scripts even on Windows. <?php $dw = new COM('DynamicWrapper'); // needs dynwrap.dll (regsvr32 dynwrap.dll) // register needed features $dw->Register('kernel32.dll', 'GetStdHandle', 'i=h', 'f=s', 'r=l'); $dw->Register('kernel32.dll', 'SetConsoleTextAttribute', 'i=hl', 'f=s', 'r=t'); $dw->Register('kernel32.dll', 'SetConsoleTitle', 'i=s', 'f=s', 'r=l'); // get console handle $ch = self::$dw->GetStdHandle(-11); // -11 = STD_OUTPUT_HANDLE ?> After these initialization steps, you can set the console output color using: <?php $dw->SetConsoleTextAttribute($ch, 14); echo 'This is yellow text!'; $dw->SetConsoleTextAttribute($ch, 7); echo 'Back to normal gray!'; ?> Using SetConsoleTitle you can even set the title displayed in the console window. Color values are 0..7 for dark colors and 8..15 for light colors. Sequence is (black/silver, blue, green, cyan, red, magenta, yellow/brown, white/gray). I also found that if you add 16384 to the value, it should be inverse. 32768 added should get underlined text. But these latter two didn't work for me. ---- Server IP: 217.13.201.10 Probable Submitter: 85.179.21.176 ---- Manual Page -- http://www.php.net/manual/en/class.com.php Edit -- https://master.php.net/note/edit/83698 Del: integrated -- https://master.php.net/note/delete/83698/integrated Del: useless -- https://master.php.net/note/delete/83698/useless Del: bad code -- https://master.php.net/note/delete/83698/bad+code Del: spam -- https://master.php.net/note/delete/83698/spam Del: non-english -- https://master.php.net/note/delete/83698/non-english Del: in docs -- https://master.php.net/note/delete/83698/in+docs Del: other reasons-- https://master.php.net/note/delete/83698 Reject -- https://master.php.net/note/reject/83698 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#140229) next »