September 12th, 2004, 04:39 PM
Sending data on keyboard
I am writing a remote control program in python, i am getting data in through a pic microprocessor on the serial port. It then makes decisions and then needs to send data out on the keyboard command, like an on screen keyboard. I need some help, how do i send a text string on the keyboard interput so that it is sent to the current open program or all programs.
September 13th, 2004, 01:30 PM
I don't know of any pre-existing Python utility that allows you to access such low-level functions. Your best bet may be to perform the interrupt generation in C as a Python extension. There is excellent documentation on how to extend Python using C in the standard Python docs.
September 17th, 2004, 01:54 PM
I have found an onscreen keyboard written in python however being quite new to python i can work out how it echos data to the keyboard
Also how would i echo data on the keyboard in c
September 20th, 2004, 02:15 PM
The onscreen example you referred to uses a module called win32com to generate the key commands. The win32com module provides the ability to interface to any Windows COM program such as MS Word, Excel, Outlook, IE, etc. There is considerable documentation available online on how to use the win32com module.
Specifically, in the example you referenced, the following lines perform the key emulation:
Line 240 is in an event handler that handles an EVT_LEFT_DOWN event. This means that whenever the user presses the left mouse button over any of the 'keys', this handler is called. And this line is the specific point at which the program emulates a key being pressed by accessing WScript.Shell through the COM interface.
26 import win32com.client
30 shell = win32com.client.Dispatch("WScript.Shell")
How to emulate keystrokes in C is beyond the scope of this Python forum. However, once you have that worked out, you then only need to extend Python with your new C function. Again,
read this for more information on how to extend Python using C.
September 20th, 2004, 02:28 PM
Linux - Thankyou
Thank you for the help so far however how would i do this in linux.
September 20th, 2004, 03:02 PM
Performing the keystroke emulation in a C extension would still apply under Linux.
September 20th, 2004, 05:14 PM
ok maybe sally, for what you will send somethind to kb??
should the key receiving the msg spring up and say
'hallo word, i am here'?
maybe i missunderstand your kb!
please call a cat a cat.