3

First, I do not know how to work with this kind of thing, let alone programming, but this site has helped me build everything I've done so far, so I came to ask a question. I want to make a batch file that opens an .exe and type a command in it. The executable file looks a lot like a cmd ...Program running the startup commands. After finishing initializing the program's plugins, it allows me to type some commands. The command in question that I want to execute is "overlay osu" (To open the game with the plugin enabled). I started with start to open the command and a timeout / t 4 to wait for the program to initialize properly, but I do not know how to make the batch file enter some command in the program after a certain time (4 seconds in that case). My command for now goes on like this:

ECHO OFF
start Sync.exe
timeout / t 4> nul

timeout / t 7> nul
exit

The empty line would be to place the command. I came to think that it would be possible if instead of opening the program in another window, try to open a new cmd and open the program inside the cmd itself with this command:

ECHO OFF
start cmd @cmd /k sync
timeout / t 4> nul

timeout / t 7> nul
exit

But anyway I do not know a command to type what I want in another program. As I said, I'm no expert, I'm just a 15-year-old boy too lazy to open the documents and type a command every time he wants to play, so any help is welcome. If it is not possible to do this type of task in a .bat, tell me in what kind of language it would be possible to program it, I will do my best to learn the basics. With everything said, I don't need the program to be closed after this, only the batch file! (sorry for anything, I do not use forums often and English is not my primary language)

1 Answer 1

0

So, can you try send key (VBS)

| Send_Enter.cmd |


@echo off && setlocal EnableDelayedExpansion

set "_vbFile=%temp%\_Enter_.VBS" && ( 
echo/ WScript.CreateObject^("WScript.Shell"^).AppActivate "display\Sync.exe"
echo/ WScript.Sleep 1000^: WScript.CreateObject^("WScript.Shell"^).SendKeys "({ENTER})" 
) >"!_vbFile!" && set "_Run_VB=%__APPDIR__%CScript.exe "!_vbFile!" //nologo

:loop
%__APPDIR__%tasklist.exe /nh | %__APPDIR__%find.exe /i "Sync.exe" >nul && ( 
start "" /wait /b !_Run_VB! && 2>nul >nul del "!_vbfile!" & endlocal & goto :EOF 
) || ( %__APPDIR__%timeout.exe /t 2 >nul & endlocal & goto :loop )

 WScript.CreateObject("WScript.Shell").AppActivate "display\Sync.exe"
 WScript.Sleep 1000
 WScript.CreateObject("WScript.Shell").SendKeys "({ENTER})"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .