在 2005年7月16日星期六 UTC+8下午8:46:34,Benji York写道:
> googlegro...@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

Recently, I tried `.AppActivate("Command Prompt")` but cannot catch the `cmd` 
on my Windows 7, the result is `False`. I know it has been some years since 
your reply, and the name of the window object may be different.(Still I'm 
pretty thankful to your answer.) Just wondering if there is a similar solution 
with another object name.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to