home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch.nt      Fun with Windows NT batch files      68,980 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 68,786 of 68,980   
   JJ to Tom Del Rosso   
   Re: Simulating a key input to an externa   
   13 May 24 10:22:34   
   
   From: jj4public@outlook.com   
      
   On Sun, 12 May 2024 18:20:37 -0400, Tom Del Rosso wrote:   
   > Is there a way to give an *external* command "any key" input without   
   > using a macro utility?   
   >   
   > Years ago there was some mention of using START /B but I can't find an   
   > example. The experiment below is just confusing with the sequence of   
   > output and input all mixed up, but both PAUSE commands still need input.   
   >   
   > And what's needed is to give input to an external command. Piping echo   
   > doesn't always work.   
   >   
   > @echo off   
   > echo TOP OF FILE   
   >   
   > if "%~1"=="JUMP" goto :%2   
   >   
   > echo FIRST RUN   
   >   
   > START "SUBC" /B "%~0" JUMP SUBC   
   >   
   > echo 1   
   > pause   
   > echo 2   
   > exit   
   >   
   >:SUBC   
   > echo 3   
   > pause   
   > echo 4   
   > exit   
      
   You can borrow Windows Script Host via VBScript to generate keypresses using   
   `WScript.Shell` object's `SendKeys` function.   
      
   https://ss64.com/vb/sendkeys.html   
      
   e.g. send ALT+ENTER sychronously:   
      
   @echo off   
   setlocal   
   > "%temp%\sendkeys.vbs" echo createobject("wscript.shell").sendk   
   ys(wsh.arguments(0))   
   cscript.exe //nologo "%temp%\sendkeys.vbs" "%{enter}"   
      
   e.g. send text asynchronously:   
      
   @echo off   
   setlocal   
   > "%temp%\sendkeys.vbs" echo createobject("wscript.shell").sendk   
   ys(wsh.arguments(0))   
   start /b cscript.exe //nologo "%temp%\sendkeys.vbs" "my input{enter}"   
   set /p "inp=enter input: "   
   echo input=%inp%   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca