How do I send keystrokes to a console window in Windows XP?

Benji York benji at benjiyork.com
Sat Jul 16 08:46:34 EDT 2005


GoogleGroups at garringer.net wrote:
> How do I use Python to send keystrokes to a console window in Windows
> XP?

import win32com.client

shell = win32com.client.Dispatch("WScript.Shell")
shell.AppActivate("Command Prompt")

shell.SendKeys("cls{ENTER}")
shell.SendKeys("dir{ENTER}")
shell.SendKeys("echo Hi There{ENTER}")
--
Benji York



More information about the Python-list mailing list