Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How can I put characters directly into the keyboard buffer?

How can I put characters directly into the keyboard buffer?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++helptutorial
7 Posts 6 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    reinhard_jd
    wrote on last edited by
    #1

    Hi all, I want to write a little tool which reads some characters from the serial port and puts them directly into the keyboard buffer, so that they appear in the currently active application at the current cursor position. Handling of the seral port isn't a problem, but can anyone give me a hint how to emulate a keystroke from within a program (C/C++, WinXp) :confused: Thanks! Reinhard

    D C K B R 5 Replies Last reply
    0
    • R reinhard_jd

      Hi all, I want to write a little tool which reads some characters from the serial port and puts them directly into the keyboard buffer, so that they appear in the currently active application at the current cursor position. Handling of the seral port isn't a problem, but can anyone give me a hint how to emulate a keystroke from within a program (C/C++, WinXp) :confused: Thanks! Reinhard

      D Offline
      D Offline
      douglasjordan
      wrote on last edited by
      #2

      Start with SendInput http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/sendinput.asp[^]

      1 Reply Last reply
      0
      • R reinhard_jd

        Hi all, I want to write a little tool which reads some characters from the serial port and puts them directly into the keyboard buffer, so that they appear in the currently active application at the current cursor position. Handling of the seral port isn't a problem, but can anyone give me a hint how to emulate a keystroke from within a program (C/C++, WinXp) :confused: Thanks! Reinhard

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #3

        You can use the SendInput function for that purpose but I don't think this is a great idea. What kind of application are you using ? Console app or windows app ? In both cases this won't work as expected. In the console app, you can only see text appear if the program reaqire some entry (cin for example) and for the window application, the control inside which you want to display the text needs to have the focus. Why don't you choose an easier solution: read the data from the serial port yourself and print it yourself. It is much more simple !

        1 Reply Last reply
        0
        • R reinhard_jd

          Hi all, I want to write a little tool which reads some characters from the serial port and puts them directly into the keyboard buffer, so that they appear in the currently active application at the current cursor position. Handling of the seral port isn't a problem, but can anyone give me a hint how to emulate a keystroke from within a program (C/C++, WinXp) :confused: Thanks! Reinhard

          K Offline
          K Offline
          kakan
          wrote on last edited by
          #4

          What about: SendMessage(hwnd, WM_CHAR, , 0);

          1 Reply Last reply
          0
          • R reinhard_jd

            Hi all, I want to write a little tool which reads some characters from the serial port and puts them directly into the keyboard buffer, so that they appear in the currently active application at the current cursor position. Handling of the seral port isn't a problem, but can anyone give me a hint how to emulate a keystroke from within a program (C/C++, WinXp) :confused: Thanks! Reinhard

            B Offline
            B Offline
            Bob Stanneveld
            wrote on last edited by
            #5

            Hello, This[^] will be helpfull. :-D Behind every great black man...             ... is the police. - Conspiracy brother Blog[^]

            1 Reply Last reply
            0
            • R reinhard_jd

              Hi all, I want to write a little tool which reads some characters from the serial port and puts them directly into the keyboard buffer, so that they appear in the currently active application at the current cursor position. Handling of the seral port isn't a problem, but can anyone give me a hint how to emulate a keystroke from within a program (C/C++, WinXp) :confused: Thanks! Reinhard

              R Offline
              R Offline
              reinhard_jd
              wrote on last edited by
              #6

              Many thanks to all of you!!! I've tried some of the hints and esp. the SendKeys object helped a lot. You've saved my day... :-D Reinhard

              T 1 Reply Last reply
              0
              • R reinhard_jd

                Many thanks to all of you!!! I've tried some of the hints and esp. the SendKeys object helped a lot. You've saved my day... :-D Reinhard

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #7

                reinhard_jd wrote:

                I've tried some of the hints and esp. the SendKeys object helped a lot.

                you can try keybd_event Function tooo

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                cheers, Alok Gupta VC Forum Q&A :- I/ IV

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups