Program write in the textbox of another

2

Hello! I used the program "Exe Lock" to block my files, everything works perfectly, the problem is that I was trying to open the file locked with a program in C # and the program itself write in the textbox that asks the password for the other to be opened, I do not know how to explain it, but here's an image: I'vealreadytriedtopassthepasswordastypeargumentlikethis:

Process.Start("Arquivo bloqueado.exe", "-password 0909288");

But it did not give a bit right, I also tried to put a redirectoutput and enter the password and even then nothing ... Anyone have any ideas, and preferably not gambiarra?

    
asked by anonymous 27.12.2016 / 23:18

2 answers

4

We can try something like this:

    Process processo = Process.Start("SICON.EXE");
    IntPtr h = processo.MainWindowHandle;
    SetForegroundWindow(h);
    processo.WaitForInputIdle(); // Isso aqui foi de extrema importância :D.
    SendKeys.SendWait("senhaaqui");
    SendKeys.SendWait("{ENTER}");
    
28.12.2016 / 14:14
1

I was able to solve with the idea of Felipe M. Martins, but I'll post here the way I left it to be very clean:

Process processo = Process.Start("SICON.EXE");
IntPtr h = processo.MainWindowHandle;
SetForegroundWindow(h);
processo.WaitForInputIdle(); // Isso aqui foi de extrema importância :D.
SendKeys.SendWait("senhaaqui");
SendKeys.SendWait("{ENTER}");
    
28.12.2016 / 20:52