php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #19545 Clipboard functions
Submitted: 2002-09-21 17:29 UTC Modified: 2011-01-01 01:05 UTC
Votes:5
Avg. Score:4.4 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:2 (50.0%)
From: xxx-nospam-php at BrazilianTranslation dot net Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.2.3 OS: Windows 95
Private report: No CVE-ID: None
 [2002-09-21 17:29 UTC] xxx-nospam-php at BrazilianTranslation dot net
Hi. I've always wanted to be able to read from and write to Windows' clipboard. It is possible in Perl, but I prefer to use PHP.
I do not intend to manipulate a Web site visitor's clipboard through CGI, I know it is impossible. It is for shell scripting only.
PHP has such an incredible number of functions, it surprises me that no such functions have been made yet.

Many thanks,
Luciano Espirito Santo

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-10 18:10 UTC] maxim@php.net
PHP is intented primarely for web - such feature would be completely off topic. I can only picture GTK using something like that...
 [2002-11-10 23:52 UTC] xxx-nospam-php at BrazilianTranslation dot net
I'm disappointed to hear that.

PHP is "intented primarely for web" (sic), but that doesn't have to rule out other uses. Several articles about the use of PHP as a shell scripting language have been written. I think it is just a natural step for anyone who makes extensive and intensive use of PHP. What is the point of php-cli.exe, anyway?

I've been messing with several other languages lately, only in search of better integration with the Windows environment, so I can make better use of shell and/or automation scripts. I've tried Perl, Ruby, Tcl, Python and even stinky VB, and a few of these languages support the Windows clipboard. Not only that, they handle CGI functions but also seek better integration with the Windows environment. Especially Python. But I don't like Python. I don't want to write in Python. I could write in Perl and not feel miserable, but I spend a lot of time writing in Perl. I know PHP, that is the one I know. I feel comfortable writing in PHP. It is an excellent language, IMO superior to all others in several aspects, why does it (still) have to be regarded as a "Web-only" language? Why can't it extend into other territories, like Python is doing and becoming ever more popular as we speak? GTK is a good point. But GTK slows everything down a little, and not all shell applications require a GUI.

I think it is just natural for any of these languages to evolve and extend its functionalities. PHP knows that. That's why PHP-cli was made, that's why its OOP (classes) implementation has been getting so much attention, that's why some effort has been made towards developing and improving its XML, COM and Windows API functions.

Anyway, if there is any other reason for not implementing clipboard functions in PHP, fine. But let it be a more reasonable one. Because if clipboard functions are "completely off topic", what to say of COM and Windows API? And if it's "for Web use only", then why bother with PHP-cli?

Thanks for the reply, at any rate.
Luciano Espirito Santo
 [2002-11-10 23:59 UTC] rasmus@php.net
You really have nothing to complain about until you submit a patch with this functionality.  Then you can argue its technical merits.  Asking us to implement a feature that none of us need is a rather impossible battle for you.
 [2002-11-11 00:13 UTC] xxx-nospam-php at BrazilianTranslation dot net
Oh, I would if I could. But I'm afraid I do not have any competence at all for that. I started programming only one year ago. I know nothing of C, for example, except that PHP inherited a lot from it so they look alike sometimes. I wouldn't know where to start.

I have no intention to put up any "battle". I just miss the feature very often, never saw any mention of it anywhere, not even in this bug/feature request section, and thought that maybe it was time someone asked for it. But if that's how the development team feels about it, case closed.

Again, thanks for the reply.
Luciano Espirito Santo


[Note to passers-by and occasional readers: reading my previous message again, I noticed that I claim to "spend a lot of time writing in Perl". It sounds as if I actually spend a lot of time writing in Perl and that I am a Perl expert. What I actually meant was that I take too long to write anything in Perl, because I do not feel comfortable with it.]
 [2002-11-11 06:24 UTC] maxim@php.net
Luciano,

Doesn't the fact that in 6 years of PHP nobody talked about integrating windows clipbard suggest you that it is a minor need and we couldn't care less about it?

There are COM functionalitites (can't these be used somehow?)... you can write a lovely Perl script that goes into your clipboard and interact with it via PHP's shell commands... and so on and  so on.

There are ways and ways to get your clipboard contents into a PHP script. Don't ask me more on how because I never even thought about it, but this should be possible as of now.

Intergating this feature into PHP core today makes few or none sense. Unless there will be a high request and a clear view why it is needed.

Maxim Maletsky
 [2011-01-01 01:05 UTC] jani@php.net
-Status: Open +Status: Bogus -Package: Feature/Change Request +Package: *General Issues
 [2011-01-01 01:05 UTC] jani@php.net
Use com: http://php.net/com
 [2012-06-29 15:09 UTC] mmellon at ecrs dot com
This feature was requested in 4.2.

In 4.2, this was trivial to do:

<?php
	function clipboard_copy($text)
	{
		$ie = new COM('InternetExplorer.Application');
		$ie->Navigate('about:blank');
		while ($ie->ReadyState != 4)
		{
			sleep(0.1);
		}
		$ie->document->ParentWindow->ClipboardData->SetData("text", 
$text);
		$ie->Quit();
	}

	clipboard_copy("foo\r\nbar");
?>

The way COM objects are handled is a bit different in PHP5 and later... the 
syntax differences are detailed here: http://devzone.zend.com/238/com_dotnet/ 
(this article is referenced in the official PHP COM class documentation)

It would still be trivial to do.

Seeing how easy this is to do, I don't think a library function is justified. 
However, I sympathize with the requestor's position about PHP being used as 
something other than a web language. I use it for GUI and command line apps all 
the time.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 16:01:36 2024 UTC