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 send a certain key to a certain application? (simulate keyboard)

How can I send a certain key to a certain application? (simulate keyboard)

Scheduled Pinned Locked Moved C / C++ / MFC
questionannouncementlounge
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.
  • A Offline
    A Offline
    andreir23
    wrote on last edited by
    #1

    I have a TV tuner with a crappy app that controls it and no scheduler to record shows. I would write my own app to schedule the startup of the crappy app and the ALT-R to begin record and again to stop it. Unfortunately all I know is that I have to send the app a certain message. Any clues guys? :-) Thank you, Andrei. LATER UPDATE: So I found you can use: PostMessage(hwnd, WM_CHAR, WPARAM('^'), LPARAM(M)); for CTRL-M But there appears 2 more questions in my mind: a) How do you do it for ALT-R or ALT-F4? Any general rule? b) How do you determine the handle of the window you want to send it to? Mine has "PCTV Vision" in the title. Any chance you have to use FindWindow? TNX!

    J _ 2 Replies Last reply
    0
    • A andreir23

      I have a TV tuner with a crappy app that controls it and no scheduler to record shows. I would write my own app to schedule the startup of the crappy app and the ALT-R to begin record and again to stop it. Unfortunately all I know is that I have to send the app a certain message. Any clues guys? :-) Thank you, Andrei. LATER UPDATE: So I found you can use: PostMessage(hwnd, WM_CHAR, WPARAM('^'), LPARAM(M)); for CTRL-M But there appears 2 more questions in my mind: a) How do you do it for ALT-R or ALT-F4? Any general rule? b) How do you determine the handle of the window you want to send it to? Mine has "PCTV Vision" in the title. Any chance you have to use FindWindow? TNX!

      J Offline
      J Offline
      john john mackey
      wrote on last edited by
      #2

      I like using Spy++ (part of the Visual Studio suite). It has several input methods - type the dialog name, 0x handle number, or select a cross-hair pointer and zap the window you want info on. Johnny

      1 Reply Last reply
      0
      • A andreir23

        I have a TV tuner with a crappy app that controls it and no scheduler to record shows. I would write my own app to schedule the startup of the crappy app and the ALT-R to begin record and again to stop it. Unfortunately all I know is that I have to send the app a certain message. Any clues guys? :-) Thank you, Andrei. LATER UPDATE: So I found you can use: PostMessage(hwnd, WM_CHAR, WPARAM('^'), LPARAM(M)); for CTRL-M But there appears 2 more questions in my mind: a) How do you do it for ALT-R or ALT-F4? Any general rule? b) How do you determine the handle of the window you want to send it to? Mine has "PCTV Vision" in the title. Any chance you have to use FindWindow? TNX!

        _ Offline
        _ Offline
        __Cerb
        wrote on last edited by
        #3

        For your b) question, here's how: HWND hwnd = ::FindWindow(NULL,"PCTV Vision"); Then you can call PostMessage using hwnd For alt+f4, you could just use ::PostQuitMessage(0); I am not sure at all on how to send (i.e: CTRL+M), but if PostMessage(hwnd, WM_CHAR, WPARAM('^'), LPARAM(M)); works, then PostMessage(hwnd, WM_CHAR, WPARAM('!'), LPARAM(R)); would do the job. One more thing. If you are coding an MFC application, you will need to add ' :: ' in front of your PostMessage's and FindWindow's, since you want to play with HWND values, and not CWnd Michael

        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