Can python access windows clipboard

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MaHL

    #1

    Can python access windows clipboard

    Can I use python to copy something(like a string) to the clipboard, so
    that I can paste it somewhere else. Is there a way to do this?

    Thanks very much!

  • Ant

    #2
    Re: Can python access windows clipboard

    On Jun 21, 9:59 am, MaHL <mhl1...@gmail. comwrote:
    Can I use python to copy something(like a string) to the clipboard, so
    that I can paste it somewhere else. Is there a way to do this?
    The following requires Mark Hammond's win32all package (http://
    sourceforge.net/projects/pywin32/):

    import win32clipboard, win32con, random

    text = "Some text to stick on the clipboard"

    win32clipboard. OpenClipboard()
    win32clipboard. SetClipboardDat a(win32con.CF_T EXT, text)
    win32clipboard. CloseClipboard( )

    --
    Ant...

    Notes on programming, cycling, climbing, linux and stuff.



    Comment

    • Gabriel Genellina

      #3
      Re: Can python access windows clipboard

      En Thu, 21 Jun 2007 05:59:06 -0300, MaHL <mhl1983@gmail. comescribió:
      Can I use python to copy something(like a string) to the clipboard, so
      that I can paste it somewhere else. Is there a way to do this?
      Yes, using the pywin32 extensions that you can download from Sourceforge

      pyfrom win32clipboard import *
      pyOpenClipboard ()
      pyEmptyClipboar d()
      pySetClipboardT ext("Hello from Python!")
      11272196
      pyCloseClipboar d()

      Ctrl-v: Hello from Python!

      --
      Gabriel Genellina

      Comment

      • Michael Hoffman

        #4
        Re: Can python access windows clipboard

        MaHL wrote:
        Can I use python to copy something(like a string) to the clipboard, so
        that I can paste it somewhere else. Is there a way to do this?
        If you're using Cygwin Python you can just open /dev/clipboard and work
        on that.
        --
        Michael Hoffman

        Comment

        • MaHL

          #5
          Re: Can python access windows clipboard

          thanks a lot!

          Comment

          Working...