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. sending input to window

sending input to window

Scheduled Pinned Locked Moved C / C++ / MFC
7 Posts 5 Posters 0 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.
  • D Offline
    D Offline
    dene99970
    wrote on last edited by
    #1

    I've attached to another window's input by calling AttachThreadInput(). I'm now trying to send text, as follows: int size = strlen(text); for(int i=0; i

    W M T H 4 Replies Last reply
    0
    • D dene99970

      I've attached to another window's input by calling AttachThreadInput(). I'm now trying to send text, as follows: int size = strlen(text); for(int i=0; i

      W Offline
      W Offline
      Waldermort
      wrote on last edited by
      #2

      strlen return the number of characters excluding the null character at the end. You are sending one less than the number with your 'i<size'. Change it to i<=size and it should work as you want.

      D 1 Reply Last reply
      0
      • W Waldermort

        strlen return the number of characters excluding the null character at the end. You are sending one less than the number with your 'i<size'. Change it to i<=size and it should work as you want.

        D Offline
        D Offline
        dene99970
        wrote on last edited by
        #3

        Nope, look at the following string: "hello" strlen returns 5, which means the following characters are sent: 0 - 'h' 1 - 'e' 2 - 'l' 3 - 'l' 4 - 'o' Besides if I send 2 string in a row still only the last character of the last string is ommitted, not the last characters of both strings.

        1 Reply Last reply
        0
        • D dene99970

          I've attached to another window's input by calling AttachThreadInput(). I'm now trying to send text, as follows: int size = strlen(text); for(int i=0; i

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          Do you have control over the code receiving the WM_CHAR message? If not then I'm not sure how you could expect the receiver to handle system messages being forced to it without knowing what message it could currently be processing or its state or anything. It seems to me posting (not sending) WM_KEYDOWN and WM_KEYUP and letting the receiver translate the WM_KEYDOWNs to WM_CHAR messages may be safer. Mark

          1 Reply Last reply
          0
          • D dene99970

            I've attached to another window's input by calling AttachThreadInput(). I'm now trying to send text, as follows: int size = strlen(text); for(int i=0; i

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

            whenwood wrote:

            SendMessage(inputHwnd, WM_CHAR, text[i], 0);

            better use SendInput api!

            "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 Support CRY- Child Relief and you

            1 Reply Last reply
            0
            • D dene99970

              I've attached to another window's input by calling AttachThreadInput(). I'm now trying to send text, as follows: int size = strlen(text); for(int i=0; i

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              See SendInput[^]


              WhiteSky


              T 1 Reply Last reply
              0
              • H Hamid Taebi

                See SendInput[^]


                WhiteSky


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

                WhiteSky wrote:

                See SendInput[^]

                humm copying me :)

                "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 Support CRY- Child Relief and you

                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