[python-win32] pasting from clip-board

Daniel F nanotube at gmail.com
Thu Apr 21 18:00:08 CEST 2005

> I am new to python WIN-32 and am trying to automate a
> word document creation. I am trying to paste clipboard
> that I capture from an application to MS Word and I
> was wondering if this can be done through python
> WIN-32. I am a doing a sequence of tests which saves
> simulation results to the clip-board and need to paste
> clip-boad to MS-Word. I was wondering if anyone has
> done something similiar

howdy ryan,

well, you could try doing a win32gui.SendMessage and send WM_COPY and
WM_PASTE messages to the applications where you want copies and pastes
to be carried out. they should be easy to play with, since the lparam
and wparam are just set to zero. so you would just get the appropriate
window handles, and then

win32gui.SendMessage(hwnd1, WM_COPY, 0, 0)
win32gui.SendMessage(hwnd2, WM_PASTE, 0, 0)

or, you could explore the functions available in the
appropriately-named win32clipboard module (the GetClipboardData
function looks like it could be appropriate for your purposes).

try the following docs for more detail:



More information about the Python-win32 mailing list