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. windows program in background and simulate keyboard

windows program in background and simulate keyboard

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 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.
  • Y Offline
    Y Offline
    Ylis
    wrote on last edited by
    #1

    1. When I create a windows program and don't have it in focus it seems to end proccessing. This is where I place my code: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } //my code here } Is there anyway I can make sure that my program is being run all the time, even if it's not in focus? 2. My second question is about simulating the keyboard, I know about PostMessage(). However, with this function I must post a key press to a certain window, what I want to do is to simulate a keypress to windows. ;P //Ylis

    P 1 Reply Last reply
    0
    • Y Ylis

      1. When I create a windows program and don't have it in focus it seems to end proccessing. This is where I place my code: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } //my code here } Is there anyway I can make sure that my program is being run all the time, even if it's not in focus? 2. My second question is about simulating the keyboard, I know about PostMessage(). However, with this function I must post a key press to a certain window, what I want to do is to simulate a keypress to windows. ;P //Ylis

      P Offline
      P Offline
      Prakash Nadar
      wrote on last edited by
      #2

      The hidden application will receive system messages but not the windows messages... Key press are windows messages and u will get it only if that window is in focus. I am sure, i guesss for your problem you need to implement a keyboard hook.


      "When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)

      Y N 2 Replies Last reply
      0
      • P Prakash Nadar

        The hidden application will receive system messages but not the windows messages... Key press are windows messages and u will get it only if that window is in focus. I am sure, i guesss for your problem you need to implement a keyboard hook.


        "When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)

        Y Offline
        Y Offline
        Ylis
        wrote on last edited by
        #3

        oki, thx :)

        1 Reply Last reply
        0
        • P Prakash Nadar

          The hidden application will receive system messages but not the windows messages... Key press are windows messages and u will get it only if that window is in focus. I am sure, i guesss for your problem you need to implement a keyboard hook.


          "When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)

          N Offline
          N Offline
          Nirav Doshi
          wrote on last edited by
          #4

          To simulate keyboard messages, I guess SendInput() would be a more appropriate option. - Nirav * Don't wish it was easier, wish you were better! *

          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