Batch File Arrow Key Navigation -


i trying make batch file highlight selection. example, when computer shutdown incorrectly, displays black screen , can use arrow keys navigate options. wondering if duplicate batch file scripting.

i followed links given in previous answer , found no useful information. 3 of links refers same choice /n /s /c:qq "solution" based on old ms-dos choice.com command, joke: previous command return different errorlevel values "q" , "q" keys. need third-party program in order read "extended keys", cursor control keys, function keys, etc.

some time ago wrote program of type named getkey.exe; returns key code of all keys in keyboard via errorlevel: ascii characters returned positive values , extended keys negative. example, uparrow key returns -72 , downarrow returns -80. batch file below create getkey.exe auxiliary program , show brief description of use:

@if (@codesection == @batch) @then   @echo off   rem create getkey.exe auxiliary program , show usage rem http://www.dostips.com/forum/viewtopic.php?f=3&t=3428 rem antonio perez ayala  echo key keyboard , return value in errorlevel. echo/ echo getkey [/n] echo/ echo ascii characters returned positive values, extended keys negative. echo/ echo if /n switch given, no wait key: return 0 if no key echo pressed. echo/  if not exist getkey.exe call :extractbinaryfile getkey.exe goto :eof   rem extract binary file hexadecimal digits placed in "resource" in .bat file  :extractbinaryfile filename.ext setlocal enabledelayedexpansion set "start=" set "end=" /f "tokens=1,3 delims=:=>" %%a in ('findstr /n /b "</*resource" "%~f0"') (    if not defined start (       if "%%~b" equ "%~1" set start=%%a    ) else if not defined end set end=%%a ) (for /f "skip=%start% tokens=1* delims=:" %%a in ('findstr /n "^" "%~f0"') (    if "%%a" == "%end%" goto decodehexfile    echo %%b )) > "%~1.hex" :decodehexfile cscript //nologo //e:jscript "%~f0" "%~1" < "%~1.hex" del "%~1.hex" exit /b  <resource id="getkey.exe"> 4d5a900003[3]04[3]ffff[2]b8[7]40[35]b0[3]0e1fba0e00b409cd21b8014ccd21546869732070726f6772616d2063616e6e6f74 2062652072756e20696e20444f53206d6f64652e0d0d0a24[7]55b5b8fd11d4d6ae11d4d6ae11d4d6ae9fcbc5ae18d4d6aeed f4c4ae13d4d6ae5269636811d4d6ae[8]5045[2]4c0102005a66d14f[8]e0000f010b01050c0002[3]02[7]10[3]10[3]20[4]40[2]10 [3]02[2]04[7]04[8]30[3]02[6]03[5]10[2]10[4]10[2]10[6]10[11]1820[2]3c[84]20[2]18[27]2e74657874[3]96[4]10[3]02[3]02[14]20[2]602e 7264617461[2]ba[4]20[3]02[3]04[14]40[2]40[8]e806[3]50e873[3]e840[3]e85f[3]803e00741866813e2f57740766813e2f77740a ff150c20400085c07419ff151020400085c074073de0[3]7508ff1510204000f7d8c3cccccccce82f[3]8bf08a06463c227509 8a06463c2275f9eb0c8a06463c20740484c075f54ec38a06463c2074f94ec3ccff2504204000ff2500204000ff2510204000ff 250c2040[363]7a20[2]6c20[6]a420[2]9a20[6]5420[10]8c20[3]20[2]6020[10]ae20[2]0c20[22]7a20[2]6c20[6]a420[2]9a20[6]9b004578 697450726f6365737300e600476574436f6d6d616e644c696e6541006b65726e656c33322e646c6c[2]ce005f6765746368[2]11 015f6b62686974[2]6d73766372742e646c6c[328] </resource>   @end   // convert ascii hexadecimal digits stdin binary string var count, output = ""; while ( !wscript.stdin.atendofstream ) {    var input = wscript.stdin.readline();    ( var index = 0; index < input.length; ) {       if ( input.charat(index) == '[' ) {          ( count = ++index; input.charat(index) != ']' ; index++ ) ;          count = parseint(input.slice(count,index++));          ( var = 1; <= count; i++ ) output += string.fromcharcode(0);       } else {          output += string.fromcharcode(parseint(input.substr(index,2),16));          index += 2;       }    } }  // write binary string output file var ado = wscript.createobject("adodb.stream"); ado.type = 2;  // adtypetext = 2 ado.charset = "iso-8859-1";  // right code page output (no adjustments) ado.open(); ado.writetext(output); ado.savetofile(wscript.arguments(0),2); // adsavecreateoverwrite = 2 ado.close(); 

for further description on getkey.exe program, examples , full listing of key codes, see this post; program #3- getkey.exe.hex.

if want show menu options, need move cursor , show highlighted text. may cursorpos.exe , colorshow.exe auxiliary programs, described @ same link above.


Comments