windows api using a handle to focus input

Discussion in 'Ruby' started by Michael Linfield, Jul 1, 2009.

  1. Alright, I have the input functions down to translate user input the
    moment it hits the terminal, however I don't want the user to be typing
    directly into the terminal for this to work o_O.

    I wrote a small C++ extension to attempt to bring the window to the
    front... however sticking the function in a - while true - loop makes it
    the only window one is able to access!! (basically you can't click on
    anything till you run the kill script)

    #### C++ Code ####

    #include <windows.h>

    HWND nHandle;

    int main()
    {
    nHandle = FindWindow(NULL, "app1");
    SetForegroundWindow(nHandle);
    return 0;
    }

    ##################

    now "app1" is the title I gave the ruby script via:

    Win32API.new('user32','SetWindowText',['p','p'], 'L').call(win,txt)

    Now I'm beginning to understand the different direction I have to move
    in.
    Somehow, I want to shove all input to the window handle (which is stored
    in the "win" variable).

    How would I redirect all keyboard input to the win handle.. for multiple
    text programs such as notepad... word... ect.

    For reference, the problem I run into is that as soon as I click off the
    command prompt window to make use of inputting text into say.. notepad..
    it no longer catches keyboard input.

    Thanks for any advice,

    - Mac
    --
    Posted via http://www.ruby-forum.com/.
    Michael Linfield, Jul 1, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dietrich
    Replies:
    1
    Views:
    626
    Joe Smith
    Jul 22, 2004
  2. Leon
    Replies:
    2
    Views:
    508
  3. =?ISO-8859-1?Q?KLEIN_St=E9phane?=
    Replies:
    3
    Views:
    440
    hanumizzle
    Oct 6, 2006
  4. Replies:
    2
    Views:
    136
    bbiker
    Oct 25, 2007
  5. Roger
    Replies:
    3
    Views:
    307
Loading...

Share This Page