Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear Clipboard?

Is it possible for python to clear the clipboard? If so ... how can I do it?

I need this so in my quiz program, students can't copy paste answers from the internet and other files.

EDIT: Im using WinXP and Python 2.6

like image 511
Katherina Avatar asked Feb 03 '12 02:02

Katherina


2 Answers

from ctypes import windll
if windll.user32.OpenClipboard(None):
    windll.user32.EmptyClipboard()
    windll.user32.CloseClipboard()

No external libraries needed.

like image 87
yak Avatar answered Oct 22 '22 17:10

yak


Yes you can for that you have to use PyWin32 module which is a python module for windows ectension.

Take a look at its EmptyClipboard method.

The EmptyClipboard function empties the clipboard and frees handles to data in the clipboard. The function then assigns ownership of the clipboard to the window that currently has the clipboard open.

like image 35
RanRag Avatar answered Oct 22 '22 17:10

RanRag