accessing clipboard via win32clipboard

This is the place for queries that don't fit in any of the other categories.

accessing clipboard via win32clipboard

Postby ayaan » Fri Jan 03, 2014 8:20 am

I am working on a project in which i have to continuouly check clipboard content. If clipboard content matches with certain specified data, then it should be deleted from clipboard. After doing a lot of googling, I find out that it can be done easily by win32clipboard api. I am using Python as a programming language. Following is a code for file(CF_HDROP) format:
Code: Select all
import win32clipboard
import win32con

def filecopy():   
    try:
        win32clipboard.OpenClipboard()
        print win32clipboard.GetClipboardData(win32con.CF_HDROP)
        win32clipboard.CloseClipboard()
    except TypeError:
        pass

Following is a code for text format:
Code: Select all
import win32clipboard
def textcopy():
    try:
        win32clipboard.OpenClipboard()
        data = win32clipboard.GetClipboardData()
        print data
        win32clipboard.CloseClipboard()
    except TypeError:
        pass

I am calling above functions in a infinite loop.

Individual function works correctly. But the problem with win32clipboard is that, after win32clipboard.OpenClipboard() command, win32clipboard lock the clipboard and only realise it after CloseClipboard() command. In between i cant copy anything in clipboard.

How can i solve this problem?? Any other suggestion are also welcome to achieve ultimate aim.

NOTE: Its not necessary to use python. You can use any other language or any other approach.
Last edited by stranac on Fri Jan 03, 2014 11:30 am, edited 1 time in total.
Reason: Merged two topics. First post lock.
ayaan
 
Posts: 3
Joined: Fri Jan 03, 2014 8:17 am

Need help with win32clipboard.SetClipboardViewer

Postby ayaan » Fri Jan 03, 2014 8:25 am

i was looking at win32clipboard.SetClipboardViewer documentation http://docs.activestate.com/activepython/2.7/pywin32/win32clipboard__SetClipboardViewer_meth.html. It says that the function adds the specified window to the chain of clipboard viewers.
What the heck does that mean??
can anyone plz elaborate???
Thanx a lot in advance.
Last edited by stranac on Fri Jan 03, 2014 11:30 am, edited 1 time in total.
Reason: Merged two topics. First post lock.
ayaan
 
Posts: 3
Joined: Fri Jan 03, 2014 8:17 am


Return to General Coding Help

Who is online

Users browsing this forum: gummygecko and 2 guests