Showing posts with label Batch file. Show all posts
Showing posts with label Batch file. Show all posts

Friday, August 21, 2026

How to open notepad and type with batch file

 @echo off

title Type Text Automation


:: 1. Open Notepad

start "" notepad.exe

echo Waiting for Notepad to open...

timeout /t 2 >nul


:: 2. Create a temporary script to type text

set "VBS_FILE=%temp%\type_text.vbs"


(

echo Set objShell = WScript.CreateObject^("WScript.Shell"^)

echo ' Make sure Notepad is the active window

echo objShell.AppActivate "Notepad"

echo WScript.Sleep 500

echo ' Type the characters

echo objShell.SendKeys "abcd"

) > "%VBS_FILE%"


:: 3. Execute the typing script

cscript //nologo "%VBS_FILE%"


:: 4. Delete the temporary script file

del "%VBS_FILE%"


echo Done!

timeout /t 2 >nul


How to create notepad file with batch file

 @echo off

title Text Steps Recorder

cls

echo ==========================================

echo TYPE YOUR STEPS BELOW (Press Enter after each line)

echo Type "EXIT" and press Enter when finished.

echo ==========================================

echo.


:loop

set /p userinput="Enter text/step: "

if "%userinput%"=="EXIT" goto end

if "%userinput%"=="exit" goto end


:: This saves what you typed into a file called keystrokes.txt

echo %userinput% >> keystrokes.txt

goto loop


:end

echo.

echo Recording saved to keystrokes.txt!

pause


How to copy txt file from notepad to new notepad using bat file - batch file

 @echo off

title Steps Replayer

cls

echo Ready to replay steps. 

echo You have 5 seconds to click inside the app where you want to type!

echo.

timeout /t 5


:: This block creates a temporary script to simulate automated typing

echo Set wshShell = wscript.CreateObject("WScript.Shell") > replay.vbs


:: This reads your saved text file and writes it into the automated typer

for /f "delims=" %%x in (portalchanges.txt) do (

    echo wshShell.SendKeys "%%x" >> replay.vbs

    echo wscript.sleep 500 >> replay.vbs

    echo wshShell.SendKeys "{ENTER}" >> replay.vbs

    echo wscript.sleep 500 >> replay.vbs

)


:: This runs the automatic typing script and then deletes the temporary file

cscript //nologo replay.vbs

del replay.vbs


echo.

echo Replay complete!

pause