0

Is there anyway to get any focus input (textBox) on any screen any app that active in the windows??

I want to create console application that read RFID tag and put the value (result) on any input box

that is focusing. please advise. Is it possible?

Jongz Puangput
  • 5,527
  • 10
  • 58
  • 96
  • 1
    Its a bit hard to understand. Do you mean the console app will get the RFID tag (eg like a barcode number) and then you want to put that value in a textbox that has focus? Maybe `Keys.Send(value)` is what you want? – Jeremy Thompson Oct 11 '14 at 04:30
  • yes, but before sending the value how should I know which element that was focus in which windows so I can send somethings to it right? @JeremyThompson – Jongz Puangput Oct 11 '14 at 04:36
  • You can use this method to Send Keys to the other applications textbox: http://stackoverflow.com/questions/15292175/c-sharp-using-sendkey-function-to-send-a-key-to-another-application - If you want to set a specific textbox in another applications to have focus then google **set textbox focus in external applications** – Jeremy Thompson Oct 11 '14 at 04:44
  • Thx, @JeremyThompson your comment is the answer! – Jongz Puangput Oct 11 '14 at 08:26

2 Answers2

1

You can use this method to Send Keys to the other applications textbox: C# using Sendkey function to send a key to another application

Community
  • 1
  • 1
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
0

You can check to see if any form is active in your windows application. If form is active, then you can check which TextBox in the form has focus:

FormCollection fc = Application.OpenForms;

        foreach (Form frm in fc)
        {
            if (frm != null)
            {
                foreach (TextBox txt in frm.Controls)
                {
                    if (txt.Focused)
                    {
                        txt.Text = "your text";
                    }
                }
            }
        }
firefalcon
  • 500
  • 2
  • 8
  • 21