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. fake input , cant understand ~.~

fake input , cant understand ~.~

Scheduled Pinned Locked Moved C / C++ / MFC
helpgame-devquestion
7 Posts 4 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.
  • L Offline
    L Offline
    leenmie
    wrote on last edited by
    #1

    I want to make a program which do a fake input. It sounds a foolish program, but I want to make it for a special purpose. I run an application (ex. a game like Age of Empire, Starcraft, so on). And then I run my program. My program create a window (use CreateWindowEx()), and now, I want anything I do on this window will do on that application (I move the mouse, the mouse(pointer) in that application move, I click the mouse, the mouse in that application click, ...). I tried to get a handle of that application and send message to it (use FindWindowEx() and SendMessage() ) but nothing happened. I also tried SendInput() and AttachThreadInput(), but I failed too. It may be really foolish, but my program need to do a task like it. Could you help me solve this problem ? -- modified at 4:38 Wednesday 18th January, 2006

    P S 3 Replies Last reply
    0
    • L leenmie

      I want to make a program which do a fake input. It sounds a foolish program, but I want to make it for a special purpose. I run an application (ex. a game like Age of Empire, Starcraft, so on). And then I run my program. My program create a window (use CreateWindowEx()), and now, I want anything I do on this window will do on that application (I move the mouse, the mouse(pointer) in that application move, I click the mouse, the mouse in that application click, ...). I tried to get a handle of that application and send message to it (use FindWindowEx() and SendMessage() ) but nothing happened. I also tried SendInput() and AttachThreadInput(), but I failed too. It may be really foolish, but my program need to do a task like it. Could you help me solve this problem ? -- modified at 4:38 Wednesday 18th January, 2006

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

      i dont know the exact solution, the games like these use directinput, it is part of the DirectX package.


      -Prakash

      L 1 Reply Last reply
      0
      • P Prakash Nadar

        i dont know the exact solution, the games like these use directinput, it is part of the DirectX package.


        -Prakash

        L Offline
        L Offline
        leenmie
        wrote on last edited by
        #3

        The game is not very important, I mean any application, such as Notepad, Paint, Wordpad ....

        O 1 Reply Last reply
        0
        • L leenmie

          The game is not very important, I mean any application, such as Notepad, Paint, Wordpad ....

          O Offline
          O Offline
          Owner drawn
          wrote on last edited by
          #4

          Didn't it work as I suggested sometime back.

          Jesus Loves:rose:

          --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

          L 1 Reply Last reply
          0
          • O Owner drawn

            Didn't it work as I suggested sometime back.

            Jesus Loves:rose:

            --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

            L Offline
            L Offline
            leenmie
            wrote on last edited by
            #5

            It didnt work at all. I'm sure send message which use SendMessage successfully ( try WM_CLOSE and it worked). But if try to send message WM_MOUSEMOVE, WM_LBUTTONDOWN or WM_KEYDOWN nothing happen. I used Spy++ and did a copy, but nothing happened. That's why I cant understand.

            1 Reply Last reply
            0
            • L leenmie

              I want to make a program which do a fake input. It sounds a foolish program, but I want to make it for a special purpose. I run an application (ex. a game like Age of Empire, Starcraft, so on). And then I run my program. My program create a window (use CreateWindowEx()), and now, I want anything I do on this window will do on that application (I move the mouse, the mouse(pointer) in that application move, I click the mouse, the mouse in that application click, ...). I tried to get a handle of that application and send message to it (use FindWindowEx() and SendMessage() ) but nothing happened. I also tried SendInput() and AttachThreadInput(), but I failed too. It may be really foolish, but my program need to do a task like it. Could you help me solve this problem ? -- modified at 4:38 Wednesday 18th January, 2006

              S Offline
              S Offline
              Stephen Hewitt
              wrote on last edited by
              #6

              I feel like I've answered this question at least three times but here we go again. Faking input using the PostMessage or PostMessage API is a hit and miss affair - It will work for some applications and not so well, if at all, with others. The reason is that there is more information associated with a message other then the HWND, the message, the WPARAM and the LPARAM. To access this extra information you use APIs such as GetMessagePos and GetMessageTime. Then there is software that calls functions such as GetAsyncKeyState (this also works for mouse buttons). This is the reason for the SendInput API - This is what you use to fake input - Unless you're faking for a particular app and you know the message techniques work. If the application uses DirectInput I'm not sure how you would proceed and if the SendInput will work. This would probably only be an issue for games. Steve

              1 Reply Last reply
              0
              • L leenmie

                I want to make a program which do a fake input. It sounds a foolish program, but I want to make it for a special purpose. I run an application (ex. a game like Age of Empire, Starcraft, so on). And then I run my program. My program create a window (use CreateWindowEx()), and now, I want anything I do on this window will do on that application (I move the mouse, the mouse(pointer) in that application move, I click the mouse, the mouse in that application click, ...). I tried to get a handle of that application and send message to it (use FindWindowEx() and SendMessage() ) but nothing happened. I also tried SendInput() and AttachThreadInput(), but I failed too. It may be really foolish, but my program need to do a task like it. Could you help me solve this problem ? -- modified at 4:38 Wednesday 18th January, 2006

                S Offline
                S Offline
                Stephen Hewitt
                wrote on last edited by
                #7

                I'm not sure on the details but this site has something to say (and something to offer) on DirectInput and faking input. Steve

                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