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. Send message to window

Send message to window

Scheduled Pinned Locked Moved C / C++ / MFC
help
16 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 David Crow

    If the target window is active, you can use SendInput().

    "Love people and use things, not love things and use people." - Unknown

    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

    C Offline
    C Offline
    capint
    wrote on last edited by
    #7

    Could you show me an example of using SendInput to send a key to an active window plz ? I find it difficult to find a specific example :(

    D 1 Reply Last reply
    0
    • C capint

      Could you show me an example of using SendInput to send a key to an active window plz ? I find it difficult to find a specific example :(

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #8

      I found this using Google.

      "Love people and use things, not love things and use people." - Unknown

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      C T 2 Replies Last reply
      0
      • D David Crow

        I found this using Google.

        "Love people and use things, not love things and use people." - Unknown

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        C Offline
        C Offline
        capint
        wrote on last edited by
        #9

        Thank you very much :D

        1 Reply Last reply
        0
        • D David Crow

          I found this using Google.

          "Love people and use things, not love things and use people." - Unknown

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

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

          DavidCrow wrote:

          I found this using Google.

          he he he Answer of yahoo getting very popular

          1 Reply Last reply
          0
          • D David Crow

            If the target window is active, you can use SendInput().

            "Love people and use things, not love things and use people." - Unknown

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            C Offline
            C Offline
            capint
            wrote on last edited by
            #11

            Plz help me one more time. I would like to know how to send WM_KEYUP by SendInput. When I send a key, it seems to be pressed forever ...

            D 1 Reply Last reply
            0
            • C capint

              Plz help me one more time. I would like to know how to send WM_KEYUP by SendInput. When I send a key, it seems to be pressed forever ...

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #12

              See here.

              "Love people and use things, not love things and use people." - Unknown

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              C 1 Reply Last reply
              0
              • D David Crow

                See here.

                "Love people and use things, not love things and use people." - Unknown

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                C Offline
                C Offline
                capint
                wrote on last edited by
                #13

                I've read many pages from the pages you gave me but I still can't find the answer :( They recommend to use SendMessage but it doesn't work with SendMessage...

                D 1 Reply Last reply
                0
                • C capint

                  I've read many pages from the pages you gave me but I still can't find the answer :( They recommend to use SendMessage but it doesn't work with SendMessage...

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #14

                  Is the problem with sending or receiving? What does your code look like?

                  "Love people and use things, not love things and use people." - Unknown

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  C 1 Reply Last reply
                  0
                  • D David Crow

                    Is the problem with sending or receiving? What does your code look like?

                    "Love people and use things, not love things and use people." - Unknown

                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                    C Offline
                    C Offline
                    capint
                    wrote on last edited by
                    #15

                    This is my code :

                    HWND windowHandle = ::FindWindow(0, _T("Test"));
                    INPUT *key;
                    ::SetForegroundWindow(windowHandle);
                    key = new INPUT;
                    key->type = INPUT_KEYBOARD;
                    key->ki.wVk = VK_CONTROL;
                    key->ki.dwFlags = 0;
                    key->ki.time = 0;
                    key->ki.wScan = 0;
                    key->ki.dwExtraInfo = 0;
                    SendInput(1,key,sizeof(INPUT));
                    key->ki.dwExtraInfo = KEYEVENTF_KEYUP;
                    SendInput(1,key,sizeof(INPUT));

                    ::SendMessage(windowHandle,WM_KEYUP,0,0); //==> No effect ?

                    D 1 Reply Last reply
                    0
                    • C capint

                      This is my code :

                      HWND windowHandle = ::FindWindow(0, _T("Test"));
                      INPUT *key;
                      ::SetForegroundWindow(windowHandle);
                      key = new INPUT;
                      key->type = INPUT_KEYBOARD;
                      key->ki.wVk = VK_CONTROL;
                      key->ki.dwFlags = 0;
                      key->ki.time = 0;
                      key->ki.wScan = 0;
                      key->ki.dwExtraInfo = 0;
                      SendInput(1,key,sizeof(INPUT));
                      key->ki.dwExtraInfo = KEYEVENTF_KEYUP;
                      SendInput(1,key,sizeof(INPUT));

                      ::SendMessage(windowHandle,WM_KEYUP,0,0); //==> No effect ?

                      D Offline
                      D Offline
                      David Crow
                      wrote on last edited by
                      #16

                      capint wrote:

                      ::SendMessage(windowHandle,WM_KEYUP,0,0); //==> No effect ?

                      What does SendMessage() return?

                      "Love people and use things, not love things and use people." - Unknown

                      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                      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