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. Sendkeys in MFC?

Sendkeys in MFC?

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
3 Posts 3 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
    Dev578
    wrote on last edited by
    #1

    How would one go about sending keystrokes to a specific (not necessarily active) window? I have been working on this for awile, so any help would be appreciated. -Dev578

    R A 2 Replies Last reply
    0
    • D Dev578

      How would one go about sending keystrokes to a specific (not necessarily active) window? I have been working on this for awile, so any help would be appreciated. -Dev578

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      If you have access to the window (either a CWnd pointer or an HWND), you could use SendMessage() to send it messages simulating keystrokes (eg: WM_KWYDOWN, WM_KEYUP, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDBLCLK). /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

      1 Reply Last reply
      0
      • D Dev578

        How would one go about sending keystrokes to a specific (not necessarily active) window? I have been working on this for awile, so any help would be appreciated. -Dev578

        A Offline
        A Offline
        andreir23
        wrote on last edited by
        #3

        Here's how I did it. I had a window "PCTV Vision" that I had to send ALT-R. I used a tool simillar to Spy++, it comes with Borland Delphi 3 and it is called Winsight32. With WInsight I selected that window and I started logging all the messages that went to that window. Then I made it active and pressed ALT-R from the keyboard. I returned to WInsight32 and looked in the message log. I found there a WM_COMMAND which he recognized as "Accelerator". I shamelessly copied the WParam and Lparam and pasted it in my program which sounds like PostMessage(hwnd,WM_COMMAND,stolen_WPARAM,stolen_LPARAM); The good part is that it works!!! ;-) :-) I never tried Spy++ because I haven't installed Visual Studio Completely and it isn't installed.

        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