Jump to content

send enter to process finish .


heziavi
 Share

Go to solution Solved by AlessandroAvolio,

Recommended Posts

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

 

press tnter.JPG

Link to comment
Share on other sites

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

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

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...