Re: Re: launching external app without flashing of cmd window

From: Date: Fri, 06 Oct 2006 00:08:06 +0000
Subject: Re: Re: launching external app without flashing of cmd window
References: 1 2  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-7330@lists.php.net to get a copy of this message
On 5 Oct 2006 at 15:28, Elizabeth Smith wrote: > kksou wrote: > > When running php-gtk using php-win on windows, and launching external > > application from within php-gtk, one will always see a brief flashing of > > a cmd window. > > > > For those interested, I've posted a solution which we have been using > > for some time at: > > > > http://www.kksou.com/php-gtk2/articles/launch-external-app-in-winxp-with > > out-the-flashing-of-cmd-window.php > > > > It basically make use of a freeware utility called cmdow utility from > > http://www.commandline.co.uk/cmdow/ that allows you to > > hide a command > > window. We find this a great tool for interfacing php-gtk with external > > applications, e.g. open a url in browser or playing a mp3 file using an > > external player. > > > > /kksou > > That's kind of way overkill to launch a url/email address on windows xp.... > and you have to use a non open-source extra application which several > antivirus programs flag... > > The trick to launching an external url/email/even generic file on > windows is to use the start command (useful for launching files with the > registered program so you're not one of those annoying people who open IE > when I use firefox) **AMEN** (the windoze HTML help has this behaviour, which I find pretty horrible) > The trick to get around the flashing dos window is to use com and > WScript.Shell > > $shell = new COM('WScript.Shell'); > $shell->Run('cmd /c start "" "' . $url . '"', 0, > FALSE); > unset($shell); > > I've also found this is about three times as fast as exec or popen on XP Another way is to use the win32std extension (mentioned the other day in the thread about "printing in windows") http://pecl.php.net/package/win32std win_shell_execute("C:\\path\\to\\some\\file.html") without any further arguments will execute the standard action on the file, equivalent to a double click in windows explorer. Which means that the file will be opened in your default browser. No flashing CMD window to be seen. Works with urls too of course. One could also execute various "right click" actions such as "edit": win_shell_execute("C:\\path\\to\\some\\file.html","edit") should open the file in your default html editor. Not very different from using a COM object I admit, but at least one does not have to dig through the - sometimes rather opaque - COM docs in order to be able to use it. The win32std documentation is 6 pages or so. The win32std extension provides the additional advantage of being able to call windows file system dialogs. Which is great if you will be foisting your application on unsuspecting windows users who, in my experience, tend to get very confused when confronted by a GtkFileChooserDialog. I guess this aspect of win32std has saved me at least 50 angry phonecalls. Cheers, -- André =========================================================== Black Holes were created when God divided by zero.

« previous php.gtk.general (#7330) next »