A Perl Script to copy text between MS Windows and X Clipboard
(A replacement for xwinclip)
Last Updated (ChangeLog):
mwinclip.pl is a simple Perl script to copy text between
Windows and X
cygwin XFree86. I wrote
xwinclip gives me too much trouble. I use
cygwin tools in Windows for a long time. When
cygwin came out with XFree86 I switched from
Hummingbard Exceed X to XFree86. I looked around and found
Here're the things I don't like about xwinclip:
- xwinclip clears away the highlighted selection right away on an xterm.
I don't like it.
- Right after starting it would work fine for a while, then slowly it'd
start acting crazy and eventually stop working. Sometimes it just exits and refuse to work
even if I restart it millions of times.
- In some xterms, it interferes with Visual selection of vim.
xclip.exe to set and get text from X Clipboard. For
gettting and setting text to Windows Clipboard it uses the Win32 Perl
Clipboard module (Comes with ActiveState Perl).
Note: I do not use or maintain it anymore. (updated: Mar-04-2012)
How it works
There's nothing fancy in this script. In every 1 second (change it if you
want) it checks the Windows and X Clipboards for texts, and if it finds
anything in one, it copies the text to the other.
How to use
xclip.exe is included but you can get the source
and compile it yourself. You only need cygwin gcc to compile.
- unzip the archive:
$ unzip mwinclip1.2.zip
$ cd mwinclip1.2
- Look at the script,
mwinclip.pl and see if you need to change
- Make sure you've
ActiveState Perl is installed in your
Note: cygwin perl will not work as it does not have the Win32 Clipboard module.
- Make sure you've Digest::MD5 perl module installed.
- Make usre
/usr/X11R6/bin is in your PATH or you'll get some DLL not found errors.
- In your Windows box, open a bash shell. Don't forget to set your
DISPLAY env variable.
$ export DISPLAY=127.0.0.1:0
$ perl mwinclip.pl
Here's an example session:
$ perl mwinclip.pl 2>/dev/null
Sun Sep 26 10:54:46 2004: Windows->X: 45 bytes
Sun Sep 26 10:54:54 2004: X->Windows: 2287 bytes
Sun Sep 26 10:55:20 2004: Windows->X: 46 bytes
Sun Sep 26 10:55:23 2004: Windows->X: 3 bytes
Sun Sep 26 10:55:27 2004: Windows->X: 3 bytes
Sun Sep 26 10:55:37 2004: X->Windows: 212 bytes
Sun Sep 26 10:56:02 2004: Windows->X: 2 bytes
I noticed every now and then
xclip.exe complaints about could not open Display.
You can ignore this error message (by sending stderr to
I do). Other than that it works well all the time.
If you use this script,
Please let me know.
Freeware. Do whatever you like with it.
THIS PROGRAM IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE
AUTHOR Muhammad A. Muquit BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
- Uses Digest::MD5 perl mdoule to detect changes in clipboard.
- Initial relase
URL of this page: