heziavi Posted September 27, 2021 Share Posted September 27, 2021 we have process to run with command when its finish its ask "press enter to continue" All the commands I give, send ENTER or CONTROL SEND do not work I attach the picture of the process, A code I wrote recently that also does not help, I even made an infinite Loop that sends ENTER and nothing happens. Is there a way to send him an ENTER to complete the process on his own? Local $hWnd=WinWaitActive("C:\Users\ADMINM~1\AppData\Local\Temp\FDT\fdt2.exe","") While 1 Sleep(2000) ControlSend($hWnd, "", "", "{TAB}{ENTER}") Sleep(1000) ControlSend($hWnd, "", "", "{ENTER}") Sleep(1000) ControlSend($hWnd, "", "", "{ENTER}") Sleep(1000) ControlSend($hWnd, "", "", "{ENTER}") Sleep(1000) ControlSend($hWnd, "", "", "{ENTER}") Sleep(1000) ControlSend($hWnd, "", "", "{TAB}{ENTER}") Sleep(1000) ControlSend($hWnd, "", "", "{ENTER}") Sleep(1000) ControlSend($hWnd, "", "", "{ENTER}") WEnd Link to comment Share on other sites More sharing options...
mikell Posted September 28, 2021 Share Posted September 28, 2021 Did you try to activate (WinActivate) the window just before sending ENTER ? Link to comment Share on other sites More sharing options...
heziavi Posted September 28, 2021 Author Share Posted September 28, 2021 I run this processor from another program in c #,the process running For sure !! , When I run the code I wrote without the loop it detects that the process is working in the background and ends properly, the problem is that it does not really send enter Link to comment Share on other sites More sharing options...
heziavi Posted September 29, 2021 Author Share Posted September 29, 2021 I noticed that for such processes it is not possible to send any command, even alt+ f4 does not work, does anyone have an idea why? Link to comment Share on other sites More sharing options...
JockoDundee Posted September 29, 2021 Share Posted September 29, 2021 7 hours ago, heziavi said: When I run the code I wrote without the loop it detects that the process is working in the background and ends properly, the problem is that it does not really send enter Did you try to activate (WinActivate) the window just before sending ENTER ? (Duplicate, emphasis added) Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
heziavi Posted September 29, 2021 Author Share Posted September 29, 2021 Yes . I try WinActivate before but its not working Link to comment Share on other sites More sharing options...
JockoDundee Posted September 29, 2021 Share Posted September 29, 2021 You need to give us the Run or Shell command you are using to start your program. Actually post all the code using the <> button in the toolbar. Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
heziavi Posted September 29, 2021 Author Share Posted September 29, 2021 This is one of the codes I tried, but I tried all the versions ShellExecute("fdt2.exe","","C:\Users\aadmin\AppData\Local\Temp\FDT") Local $hWnd=WinWait("C:\Users\admin\AppData\Local\Temp\FDT\fdt2.exe","") WinActivate($hWnd,"") Sleep(2000) ControlSend($hWnd, "", "", "{ENTER}") Sleep(2000) ControlSend($hWnd, "", "", {ENTER}") Sleep(2000) ControlSend($hWnd, "", "", "{ENTER}") Sleep(2000) ControlSend($hWnd, "", "", "{ENTER}") Sleep(2000) ControlSend($hWnd, "", "", "{ENTER}") Sleep(2000) ControlSend($hWnd, "", "", "{ENTER}") Sleep(1000) ControlSend($hWnd, "", "", "{ENTER}") Even if put in an infinite loop it does not work!!!!! While 1 Sleep(2000) ControlSend($hWnd, "", "", "{ENTER}") Sleep(1000) ControlSend($hWnd, "", "", 'abc') Sleep(1000) ControlSend($hWnd, "", "", "{ENTER}") Sleep(1000) ControlSend($hWnd, "", "", "{ENTER}") Sleep(1000) ControlSend($hWnd, "", "", "{ENTER}") Sleep(1000) ControlSend($hWnd, "", "", "{ENTER}") Sleep(1000) ControlSend($hWnd, "", "", "{ENTER}") Sleep(1000) WEnd Link to comment Share on other sites More sharing options...
AlessandroAvolio Posted September 29, 2021 Share Posted September 29, 2021 You said that the window closes normally if you press ENTER with the keyboard. Let's try to understand if the problem is the focus. Let's try to send the ENTER key with SEND command after the focus has been activated by clicking the mouse on the window. Replace in $aCoord array the coordinates of a point of the window you want to close. Main() Func Main() Local Const $aCoord[2] = [634, 355] ; put coords window Sleep(1000) MouseClick("left", $aCoord[0], $aCoord[1]) Sleep(1000) Send("{ENTER}") Return 0 EndFunc Link to comment Share on other sites More sharing options...
heziavi Posted September 29, 2021 Author Share Posted September 29, 2021 It's certainly not related to focus, if I run cmd.exe and send enter or a character everything works, it's probably impossible to send commands to it, just like it's not possible to send a password to a Bitlocker when running manage-bde -changepassword 😄 Its some problem. Link to comment Share on other sites More sharing options...
AlessandroAvolio Posted September 29, 2021 Share Posted September 29, 2021 Have you tried running the code I gave you in the previous comment? If the keyboard commands work, there's really no reason the test shouldn't work. Make sure you paste the code into a new project. Link to comment Share on other sites More sharing options...
JockoDundee Posted September 29, 2021 Share Posted September 29, 2021 3 hours ago, heziavi said: Its some problem. Why not just: RunWait("C:\Users\admin\AppData\Local\Temp\FDT\fdt2.exe", "C:\Users\admin\AppData\Local\Temp\FDT") and forget all the Sends. btw, I changed “aadmin” to “admin” in the working directory path. If this was not a typo, change it back to aadmin. Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
heziavi Posted September 29, 2021 Author Share Posted September 29, 2021 i send it mistake aadmin i change already before ::))) , believe me its not working. any way i add moving that i add ALT+F4 and ENTER and you see its working all the program(CHROME, TEXT , FOLDER) , but this process not send and get any key i do while 1 https://drive.google.com/file/d/1OH3m_Yfq2gC_jcpOkE_zer79ltC3l9Fx/view?usp=sharing Link to comment Share on other sites More sharing options...
AlessandroAvolio Posted September 29, 2021 Share Posted September 29, 2021 In the video, you didn't wait for the program to say "Press ENTER to continue". If the keyboard commands do not work, it is normal that the Sends do not work either. Link to comment Share on other sites More sharing options...
heziavi Posted September 29, 2021 Author Share Posted September 29, 2021 Shure shure . I not see you. But i send alt+f4 I not wanting in video while processing finish. You want i see you? I send more videos. Its not working. Link to comment Share on other sites More sharing options...
AlessandroAvolio Posted September 29, 2021 Share Posted September 29, 2021 Try to put #Requireadmin at the top of code and run your exe with Run and @SW_SHOWNORMAL as third parameter show_flag. Next put some send commands to test if now the window receives keyboard input. #RequireAdmin Run("C:\Program.exe","", @SW_SHOWNORMAL) sleep(5000) Send("{ENTER}") sleep(1000) Send("{!{F4}") Link to comment Share on other sites More sharing options...
heziavi Posted September 29, 2021 Author Share Posted September 29, 2021 this is video with "press enter to continue" its not working https://drive.google.com/file/d/1OH3m_Yfq2gC_jcpOkE_zer79ltC3l9Fx/view?usp=sharing i will try what you send now and i will update . Link to comment Share on other sites More sharing options...
heziavi Posted September 29, 2021 Author Share Posted September 29, 2021 this is video with "press enter to continue" its not working https://drive.google.com/file/d/1OH3m_Yfq2gC_jcpOkE_zer79ltC3l9Fx/view?usp=sharing i will try what you send now and i will update . Link to comment Share on other sites More sharing options...
heziavi Posted September 29, 2021 Author Share Posted September 29, 2021 Run("C:\Program.exe","", @SW_SHOWNORMAL) sleep(5000) Send("{ENTER}") its workingggggggggg!!!!! thanks thanks thanks now you solve me how i send to manage-bde -changepassword 😄 its not working . its not send password and enter AlessandroAvolio 1 Link to comment Share on other sites More sharing options...
Solution AlessandroAvolio Posted September 29, 2021 Solution Share Posted September 29, 2021 I am happy. Unfortunately I don't know the application, can't you try the same way? And if you copy and paste the text, does it work? You could try with Clipput and then with Send ("^ v"). I can't tell you anything else Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now