Re: How can I know both the Key c and Ctrl on the keyboard are pressed?
En Tue, 30 Jan 2007 05:50:29 -0300, <[EMAIL PROTECTED]> escribió: > 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 If you are on Windows and want to trap the Ctrl-C combination, just catch the KeyboardInterrupt exception: --- cut --- from time import sleep while 1: try: sleep(1) except KeyboardInterrupt: print "Ctrl-C pressed" --- cut --- -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I know both the Key c and Ctrl on the keyboard are pressed?
"Szabolcs Nagy" <[EMAIL PROTECTED]> wrote: > 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 > Your humble opinion is wrong. Under windows Ctrl-C raises KeyboardInterrupt just as it does under linux. Ctrl-break by default terminates the program (without invoking Python's usual cleanup), but you can override that behaviour by registering a different signal handler. e.g. import signal signal.signal(signal.SIGBREAK, signal.default_int_handler) will make Ctrl-break raise KeyboardInterrupt just like Ctrl-C. -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I know both the Key c and Ctrl on the keyboard are pressed?
On 30 Jan 2007 05:44:40 -0800, Szabolcs Nagy <[EMAIL PROTECTED]> wrote: > 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 No it is KeyboardInterrupt in Windows too. -- mvh Björn -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I know both the Key c and Ctrl on the keyboard are pressed?
[EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
How can I know both the Key c and Ctrl on the keyboard are pressed?
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 -- http://mail.python.org/mailman/listinfo/python-list