Catching all input and sending it to another program

This is a discussion on Catching all input and sending it to another program within the C Programming forums, part of the General Programming Boards category; Ok so I realise this sounds almost exactly like a keylogger, but hear me out first :P What I am ...

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    16

    Catching all input and sending it to another program

    Ok so I realise this sounds almost exactly like a keylogger, but hear me out first :P

    What I am planning on doing is creating a program that will allow me to have 1 instance of a game on monitor 1, another instance on monitor 2, then with two 360 controllers be able to play them both independently on a LAN like setup. Prettymuch turning my PC into a games console.

    Essentially what I want to make is a program that catches all input (keyboard, game controller, etc). Then send it to another program (once I am that far sending to the second shouldn't be a problem.

    It isn't a problem that the same data is sent to each game instance as they can both have controller settings and it won't interfere with anything, although thinking about it, once the program has been made it wouldn't be difficult to separate the different inputs into each window.

    The question is what calls do I need to make? How do you catch data from game controllers? how do you send the inputs to another program?

  2. #2
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by RedWind View Post
    Prettymuch turning my PC into a games console.
    Why not just buy a console?
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    16
    Quote Originally Posted by QuantumPete View Post
    Why not just buy a console?
    That isn't really the issue.

    EDIT: accidently pressed submit too early

    There are many reasons:

    I'd like to learn how to do this, learning how to send input to a program would be useful for automatically logging me into X program and not having to remember Y password, or many other applications really

    The key input part I think is kinda interesting, I've never had to do this before but am finding it hard to find what I want because it's the same as what a keylogger uses.

    The game(s) are PC only

    I'd like it to be possible for several ppl to play on my PC at once, playing things on emulators is the closest to it.
    Last edited by RedWind; 09-15-2008 at 02:54 AM.

  4. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    I guess RedWind will be learning c now too
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  5. #5
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by RedWind View Post
    I'd like it to be possible for several ppl to play on my PC at once, playing things on emulators is the closest to it.
    I'm still not understanding what you want to do that can't be done with a LAN. What's your programming experience like?

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  6. #6
    Registered User
    Join Date
    Sep 2008
    Posts
    16
    Quote Originally Posted by MK27 View Post
    I guess RedWind will be learning c now too
    I know C/C++ as well as C#, I don't have a problem with I/O on an app that I am in control of, I just don't know how to catch messages that have been sent to another window and send them to another window. I apologise if my tone has inappropriate for this forum, I have a good idea of what I need to do, I just thought someone could show me to the correct API calls I need to make and if I'm lucky give an example of how to use it/them.

  7. #7
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by RedWind View Post
    I apologise if my tone has inappropriate for this forum,
    No, I should apologize. I was a little confused about the meaning of keylogger

    All I know is that if this were linux you'd start with Xlib, and I wouldn't even try.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  8. #8
    Registered User
    Join Date
    Sep 2008
    Posts
    16
    Quote Originally Posted by QuantumPete View Post
    I'm still not understanding what you want to do that can't be done with a LAN. What's your programming experience like?

    QuantumPete
    I know it's easy on a LAN, but that requires two PCs and two controller hubs and that takes time to setup. When one PC can handle two instances of a game running simultaniously the only thing stopping both playing is that only one window is active at a time.

    I have good programming experience of C/C++, I don't really know how to quantify experience, I know some C++ gurus are genius's so i dont wanna go beyond good.

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    It is not too difficult to catch all input (relatively speaking). The difficult time comes when you have to send it back into the targetted application. Because there are so many different ways that input is processed, you'd have to get pretty deep into the OS stack to get your captured input back into the application.

    I'm pretty sure that it's POSSIBLE, but it would be very far from trivial.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #10
    Registered User
    Join Date
    Sep 2008
    Posts
    21
    I don't know if this would help, but have you thought of using IPC
    (inter process communication) messaging.
    I use it for communication between a database engine and applications.

    Here is a URL that explains it.

    IPC Messages

    I have used this with great success.

  11. #11
    C/C++ Learner & Lover
    Join Date
    Aug 2008
    Location
    Argentina
    Posts
    193
    Mmm.. you want to capture the imputs from the controller and use it in a program? you could capture the keyboard imputs and convert them into the pre defined keys of the game by using the keyboard events

  12. #12
    Registered User
    Join Date
    Sep 2008
    Posts
    16
    My searching so far has unturned two key commands GetMessage and PostMessage.

    GetMessage returns 1 for a message, -1 for an error otherwise 0. Inside getmessage is the handle for the window I want the messages for, a filter and a pointer to the actual message.

    Postmessage will send a message to whatever window handle, and seems to have "message specific parameters" as well (?)

    Does anyone have a clue how to filter messages for just keyboard/controller inputs?

  13. #13
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I don't believe you have a choice about which messages you filter, you will receive any message sent to that window (but I think if some other process is also listening for messages for that window, you have a race conditon where whichever process asks first for the message "wins").

    As for the parameters, surely you would want to send out the same message set as you recieve.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  14. #14
    Registered User
    Join Date
    Sep 2006
    Posts
    230
    Just to make things clear, you want some API that will allow you to sign into Windows Live Messenger just by opening the application, so the application will input your email, password, and click submit for you?

    I don't quite understand how you'd use this API to play two instances of the game on 1 computer but with two screens.. Why can't you just make it like any other game?

    Sorry I know I'm not helping you, I'm just trying to clarify things so maybe I could benefit too
    I might not be a pro, but I'm usually right

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sending keyboard input
    By el3ktr1k in forum C Programming
    Replies: 4
    Last Post: 06-05-2009, 08:31 AM
  2. Sending key input to another process
    By sunjayc99 in forum C Programming
    Replies: 2
    Last Post: 07-04-2008, 12:02 PM
  3. Sending input from HTML/PHP to C
    By Dyshein in forum C Programming
    Replies: 2
    Last Post: 04-30-2006, 04:39 AM
  4. Replies: 1
    Last Post: 12-01-2005, 09:41 AM
  5. sending input
    By X PaYnE X in forum Windows Programming
    Replies: 0
    Last Post: 06-08-2005, 12:11 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21