Sendkeys from command prompt

Without creating temporary files. The 'loop' was shown only so that you could open a notebook for output. Remove it after.

    @echo off
        :loop
            ::------------begin main code------------
            set command=new ActiveXObject('WScript.Shell').SendKeys('WoW{ENTER}{ENTER}');
            for /f "delims=" %%i in ('mshta "javascript:%command%close(new ActiveXObject('Scripting.FileSystemObject'));"') do set "var=%%i"
            ::-------------end main code-------------
            timeout /t 1 /nobreak >nul
        goto :loop

You can use vbscript. For example, this script will mute the speakers.

set shell = CreateObject("WScript.Shell")
shell.run"Sndvol"
WScript.Sleep 1500
shell.SendKeys"{TAB}"
shell.SendKeys" "
shell.SendKeys"%{F4}"

You launch it from the console with

cscript mute.vbs

More infos here


Here is a one line solution: This line will type "Testing 123" and then hit Enter.

echo >script.vbs set shell = CreateObject("WScript.Shell"):shell.SendKeys "Testing 123{ENTER}" & script.vbs

Tags:

Cmd

Sendkeys