Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sendkeys from command prompt

Tags:

cmd

sendkeys

Is there a way to use sendkeys (or something equivalent) from (not to) the command prompt?

like image 500
Eugene Avatar asked Mar 14 '12 20:03

Eugene


People also ask

How do I press Enter in CMD?

Open a command prompt, type start /? and hit Enter.

How do I paste into a run command?

Make sure the Enable Ctrl key shortcuts option is checked. You can also check the Use Ctrl+Shift+C/V as Copy/Paste option. Click OK to save the setting. Then you should be able to use the keyboard shortcut Ctrl + C and Ctrl + V to copy and paste in Command Prompt window.


1 Answers

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
like image 140
Garric Avatar answered Oct 12 '22 12:10

Garric