ti***********@tom.com wrote:
Hi;
How can I know the Key c and Ctrl on the keyboard are pressed? Or how
to let the program press the
key Ctrl+c automatically? I just want to use python to develop a
script program.
gear
depends on where you got your input from and what do you exactly want
eg:
in a gui app you get input events from the gui toolkit (wx, gtk, sdl/
pygame...)
in a console app if you use curses lib then you can use getch() oslt
if you want a general solution to get input key events in a simple
script then you cannot do that.
however Ctrl+C is a special key combination: running python in a unix
terminal it raises KeyboardInterrupt exception, imho in a windows cmd
promt it raises SystemExit
so you can emulate those by using:
raise KeyboardInterrupt
or
raise SystemExit
hope this helps