You aren't a noob, it's a heavy trick.
I forgot to say, that you need a file (in this case "1")
Then you got these lines typing "qwertz"
Code: Select all
C:1 (J/N)? q
C:1 (J/N)? w
C:1 (J/N)? e
C:1 (J/N)? r
C:1 (J/N)? t
C:1 (J/N)? z
C:1 (J/N)?
You didn't need to press enter to get a new line, and that is important
create a file with the current pressed keys, and as it contains newlines it is created "on the fly".
So another process can parse the file to detect the latest pressed key.
To start a new task in the same window you can use vbscript or simply
or
Code: Select all
call "%~f0" :task2 | call "%~f0" :task1
As a pipe starts each part in his own task.
The trick is build by Tom Lavedas, his code is (from
alt.msdos.batch.nt)
Code: Select all
@if (@X)==(@Y) @goto :Dummy @end/* Batch part
@echo off
set "Input="&setlocal&set delay=3000 %/ milliseconds /%
set _d=>%temp%.\tmp1&set _d=>%temp%.\tmp2
set /p Input=Enter key here: < nul
for /f "delims=" %%I in (
'cscript //nologo //e:jscript "%~f0" %delay%'
) do endlocal & set "Input=%%I"
del %temp%.\tmp?.
echo.
echo.For example: "%Input%"
goto :EOF
Jscript part */
var con=new ActiveXObject("Scripting.filesystemobject")
.opentextfile("con",2);
var d=WSH.Arguments(0),t=0,s='\x01';
var cmd="xcopy %temp%.\\tmp1 %temp%.\\tmp2 /p /y<con";
var sh=new ActiveXObject("WScript.Shell");
with(sh){with(Exec("%comspec% /c"+cmd)){
while(s=='\x01'){s='\x01';
WSH.Sleep(240);t+=250;
sh.AppActivate(ProcessID);sh.sendkeys("^A");
while(s!='?')s=StdOut.Read(1);StdOut.Read(1);
s=StdOut.Read(1);if(t>d){s='Timeout';break}}
sh.AppActivate(ProcessID);sh.sendkeys("n")}}
con.Write(s); // shows keyed character [optional]
WSH.Echo(s)
jeb