What term/topic and I looking for?

Started by
7 comments, last by Hardcharger 14 years ago
I am trying to research how to send input to a window and receive information about the without being in focus. I would like to implement this using C++ and manipulating windows on a Windows operating system.
Advertisement
If by "input" you mean keyboard and mouse state, I believe DirectInput allow you to get that information while your window is not in focus. I haven't ever used it though.
You are looking for Keyboard Hooking.

SendMessage would cover the first part, assuming Windows. Could you clarify what kind of thing you want to monitor in the other program?
[TheUnbeliever]
Need more information. If you mean by "send input" that you want to inject keystrokes and mouse events to the foreground process from a background process you can do this with the API call SendInput(), although I think Microsoft might have crippled this call under Vista and later. As for receiving input, I'm not sure what you mean. Depending on what you mean you might be talking about installing a global hook, like the low-level keyboard hook, etc.
Quote:Original post by Dragon88
If by "input" you mean keyboard and mouse state, I believe DirectInput allow you to get that information while your window is not in focus. I haven't ever used it though.


Hmm, that sounds like a viable option but I think I'm looking for something else.

I'll try to explain it further:

I wrote a game in C++ and I'm trying to figure out how to write a program that loads my game and plays it for me and tests it without being in focus (possibly when minimized, too).

This way I can do testing and still use my computer for other purposes.
Quote:Original post by Toolmaker
You are looking for Keyboard Hooking.


Is there a Mouse Hook as well?

Quote:Could you clarify what kind of thing you want to monitor in the other program?


I would like to get pixel information but I'm assuming I can do that with the keyboard hook?

Also, I'd like to analyze memory but that part is easy.
Quote:Original post by Hardcharger
I wrote a game in C++ and I'm trying to figure out how to write a program that loads my game and plays it for me and tests it without being in focus (possibly when minimized, too).

This way I can do testing and still use my computer for other purposes.


So it's a windowed game, not fullscreen exclusive? Even in this case, you're not going to be able to use SendInput(), or anything else, to inject input events if it is minimized or even just not it focus. When you type on the keyboard Windows sends the events to the child window (of the active window of the foreground process) that has keyboard focus, period.

I mean you could use some kind of interprocess communication -- maybe something as simple as SendMessage-ing a custom message -- but that just begs the question of why you want to drive the testing with a separate process. Since you wrote the game, couldn't you just do whatever you want to do testing-wise in the application itself? -- and just #ifdef this code out if a special preprocessor flag isn't defined.
Quote:Original post by jwezorek
Quote:Original post by Hardcharger
I wrote a game in C++ and I'm trying to figure out how to write a program that loads my game and plays it for me and tests it without being in focus (possibly when minimized, too).

This way I can do testing and still use my computer for other purposes.


couldn't you just do whatever you want to do testing-wise in the application itself? -- and just #ifdef this code out if a special preprocessor flag isn't defined.


From the information I've received so far and further google searches, the program I write for testing injects code and handles the keyboard and mouse hooks. Adding the testing inside of the game code would be more of a hassle as I'd have to remove it before distributing it. The users could basically "bot" if I allowed this to be released

This topic is closed to new replies.

Advertisement