#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    3
    Rep Power
    0

    Sending data on keyboard


    Hello
    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.

    Thanks
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    27
    Rep Power
    0
    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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    3
    Rep Power
    0

    Osk


    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

    http://www.meru.org.uk/twiki/bin/view/Speechmakers/OnScreenKeyboard

    Also how would i echo data on the keyboard in c

    Thank you
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    27
    Rep Power
    0
    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:
    Code:
    26  import win32com.client
    30  shell = win32com.client.Dispatch("WScript.Shell")
    240              shell.SendKeys(key.keyaction)
    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.

    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.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    3
    Rep Power
    0

    Linux - Thankyou


    Thank you for the help so far however how would i do this in linux.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    27
    Rep Power
    0
    Performing the keystroke emulation in a C extension would still apply under Linux.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jul 2004
    Location
    Middle Europa
    Posts
    1,200
    Rep Power
    13
    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.

IMN logo majestic logo threadwatch logo seochat tools logo