Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I paste some string to the active window in Python? [duplicate]

Tags:

python

windows

Possible Duplicate:
How do I copy a string to the clipboard on Windows using Python?

Can someone make me an example or explain to me how can I paste something to the active window with Python?

I've edited because I didn't know that paste to the clipboard doesnt paste to the active window...

like image 486
Bruno 'Shady' Avatar asked Jul 21 '26 18:07

Bruno 'Shady'


1 Answers

since you haven't accepted the duplicate as an answer may i suggest:

import win32com.client
shell = win32com.client.Dispatch("WScript.Shell")
shell.SendKeys('keys to send to active window...')

from:

here

and if you need to find out about keys like Backspace go to

here

like image 166
jma Avatar answered Jul 23 '26 08:07

jma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!