[python-win32] Passing a keystroke through to windows

Tim Roberts timr at probo.com
Fri Aug 19 13:02:09 EDT 2016


Jacob Kruger wrote:
> I want to be able to pass ctrl+C through to windows to automatically 
> copy selected text to clipboard, before then parsing it with 
> win32clipboard, all of this invoked by calling a compiled (py2exe) app 
> sort of in the background, by invoking a desktop shortcut, with a keystroke?
>
> Is this likely to be possible at all?

So, are you saying that you have text selected in some random
application, and you want to have a keyboard shortcut that copies that
text to the clipboard, and launches an application to process it?

The answer is "maybe".  You can have your application start up, then
hide itself to figure out who the "topmost application" is.  Then, for
many applications, you can send a WM_COPY message to tell the app to
copy to the clipboard.  There are some apps where you'll actually have
to send a Ctrl-C sequence.

Once that's done, your app can pop back to the top and fetch from the
clipboard.


> Ask since while can already work with the clipboard, the user wants to 
> automatically invoke the copying to clipboard at the same time?

I'm not sure what you're asking here.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list