Hi,
i'm using WinPE and i'm creating menus with choice command.
But i want to use arrow keys to navigate my menus. is it possible?
Thanks
Best Answer grrrd , 08 February 2016 - 02:32 PM
You can see if Nircmd will work, i use that on full Windows, never tried on PE.
http://www.nirsoft.n...ils/nircmd.html
Go to the full postPosted 04 February 2016 - 11:02 AM
Hi,
i'm using WinPE and i'm creating menus with choice command.
But i want to use arrow keys to navigate my menus. is it possible?
Thanks
Posted 05 February 2016 - 08:06 AM
You need a program, *like* (examples):
http://www.dostips.c....php?f=3&t=3428
http://binnyva.com/pro/dos/batch_tk/
Wonko
Posted 05 February 2016 - 08:26 AM
You need a program, *like* (examples):
http://www.dostips.c....php?f=3&t=3428
http://binnyva.com/pro/dos/batch_tk/
Wonko
Thank you,
the main problem it's that i'm using a basic WinPE x86 and another one x64, and does program doesn't work in x64
But i found a perfect solution and it's amazing how it works
Now i'm only trying to put a menu title in there, that's another history.
Thanks once again
This is the nice batch: http://www.dostips.c....php?f=3&t=5661
Posted 05 February 2016 - 05:01 PM
AutoIt or AutoHotkey might be able to do the trick too. Just convert your script into a standalone *.exe so it can run without needing either program to be installed.
Posted 07 February 2016 - 11:02 PM
Now that i've a great menu using arrow keys, i need to center the window on the screen, is it possible?
my startnet.cmd opens my menu.cmd and i want that menu opened in center of the screen.
If a adjust the window properties it works well, but after restart it's not centered
thanks
Posted 08 February 2016 - 02:32 PM Best Answer
You can see if Nircmd will work, i use that on full Windows, never tried on PE.
http://www.nirsoft.n...ils/nircmd.html
Posted 08 February 2016 - 07:25 PM
Posted 13 February 2016 - 11:07 PM
I adapted the batch file in the dostips link. Copy it into a separate .cmd file.
This version allows the caller to specify a list of phrases and returns the selection in the var variable
If you don't specify any argument then a test list will be used.
Note: better version a few posts down!
@if (@CodeSection == @Batch) @then rem Usage: xxx.cmd "first choice" "second choice" third fourth rem Returns user choice as var variable - e.g. var=first choice rem Screen is cleared on exit @echo off setlocal EnableDelayedExpansion rem Multi-line menu with options selection via DOSKEY rem Antonio Perez Ayala rem Define the options set numOpts=0 if "%1" equ "" set OPT="This is the First" Second Third Fourth Fifth "666 66" "777 777" 888 999 10101 111 1212 if not "%1" equ "" set OPT=%* for %%a in (%OPT%) do ( set /A numOpts+=1 set aa=%%a set option[!numOpts!]=!aa:"=! ) set /A numOpts+=1 set "option[!numOpts!]=exit" rem Clear previous doskey history doskey /LISTSIZE=!numOpts! rem Fill doskey history with menu options cscript //nologo /E:JScript "%~f0" EnterOpts for /L %%i in (1,1,%numOpts%) do set /P "var=" :nextOpt cls rem echo MULTI-LINE MENU WITH OPTIONS SELECTION rem echo/ rem Send a F7 key to open the selection menu cscript //nologo /E:JScript "%~f0" > nul set var= set /P "var=Select the desired option: " > nul endlocal & set var=%var% doskey /LISTSIZE=0 cls goto :eof @end var wshShell = WScript.CreateObject("WScript.Shell"), envVar = wshShell.Environment("Process"), numOpts = parseInt(envVar("numOpts")); if ( WScript.Arguments.Length ) { // Enter menu options for ( var i=1; i <= numOpts; i++ ) { wshShell.SendKeys(envVar("option["+i+"]")+"{ENTER}"); } } else { // Enter a F7 to open the menu wshShell.SendKeys("{F7}"); wshShell.SendKeys("{HOME}"); }
Posted 14 February 2016 - 10:27 AM
Posted 14 February 2016 - 11:02 AM
Good.
Just for the record (and in case of similar use) this:
for %%a in (%OPT%) do ( set /A numOpts+=1 set aa=%%a set option[!numOpts!]=!aa:"=! )
can be simplified into a one-liner:
for %%a in (%OPT%) do set /A numOpts+=1&&set option[!numOpts!]=%%~a
Wonko
Posted 14 February 2016 - 11:13 AM
Posted 14 February 2016 - 11:30 AM
If you don't want an exit entry then delete the two lines:
set /A numOpts+=1 set "option[!numOpts!]=exit"
Not sure if it works in your WinPE, but you can also try these commands to change the console window
TITLE Mytitle mode con: cols=90 lines=30 color 1f
Posted 14 February 2016 - 11:54 AM
Posted 14 February 2016 - 12:14 PM
@if (@CodeSection == @Batch) @then @echo off rem Usage: xxx.cmd "first choice" "second choice" third fourth rem Returns user choice as var variable - e.g. var=first choice rem Screen is cleared on exit setlocal EnableDelayedExpansion rem Multi-line menu with options selection via DOSKEY rem Antonio Perez Ayala rem Define the options set numOpts=0 set OPT=%* if not DEFINED OPT set OPT="This is the First" Second Third Fourth Fifth "666 66" "777 777" 888 999 10101 111 1212 for %%a in (%OPT%) do set /A numOpts+=1&&set option[!numOpts!]=%%~a rem Clear previous doskey history doskey /LISTSIZE=!numOpts! rem Fill doskey history with menu options cscript //nologo /E:JScript "%~f0" EnterOpts for /L %%i in (1,1,%numOpts%) do set /P "var=" cls rem Send a F7 key to open the selection menu cscript //nologo /E:JScript "%~f0" > nul set var= set /P "var=Select the desired option: " > nul endlocal & set var=%var% doskey /LISTSIZE=0 cls goto :eof @end var wshShell = WScript.CreateObject("WScript.Shell"), envVar = wshShell.Environment("Process"), numOpts = parseInt(envVar("numOpts")); if ( WScript.Arguments.Length ) { // Enter menu options for ( var i=1; i <= numOpts; i++ ) { wshShell.SendKeys(envVar("option["+i+"]")+"{ENTER}"); } } else { // Enter a F7 to open the menu wshShell.SendKeys("{F7}"); wshShell.SendKeys("{HOME}"); }
Here is improved version with Wonko's suggestion + some bugs fixed when using command parameters with double-quotes and it now does not echo rem lines.
I think the size of the DOSKEY window is fixed?
Edited by steve6375, 14 February 2016 - 12:17 PM.
Posted 14 February 2016 - 12:16 PM
Posted 14 February 2016 - 12:47 PM
I didn't try these tools.
But there's a powershell solution to increase/decrease winWidth/Height as well as bufWidth/Height.
Tested on WinXP with SP3 and Win10.
Here's an example. Adapt it to your needs:
:: Console Resize values via PowerShell (changeable) SET "_PSResize=100 54 100 9997" :: Check for powershell via PATH variable POWERSHELL "Exit" >NUL 2>&1 && SET "_PS=1" IF NOT DEFINED _PS (ECHO No&do something) ELSE (ECHO Yes&do something) :: PS-Console Resizing IF DEFINED _PS CALL:_PS_ReSize %_PSRESIZE% :_PS_Resize bufWidth bufHeight winWidth winHeight :: Mode sets buffer size-not window size MODE %1,%2 :: resize powershell -command "&{$H=get-host;$W=$H.ui.rawui;$B=$W.buffersize;$B.width=%3;$B.height=%4;$W.buffersize=$B;}" GOTO:EOF
Posted 14 February 2016 - 12:59 PM
I didn't try these tools.
But there's a powershell solution to increase/decrease winWidth/Height as well as bufWidth/Height.
Tested on WinXP with SP3 and Win10.
Here's an example. Adapt it to your needs::: Console Resize values via PowerShell (changeable) SET "_PSResize=100 54 100 9997" :: Check for powershell via PATH variable POWERSHELL "Exit" >NUL 2>&1 && SET "_PS=1" IF NOT DEFINED _PS (ECHO No&do something) ELSE (ECHO Yes&do something) :: PS-Console Resizing IF DEFINED _PS CALL:_PS_ReSize %_PSRESIZE% :_PS_Resize bufWidth bufHeight winWidth winHeight :: Mode sets buffer size-not window size MODE %1,%2 :: resize powershell -command "&{$H=get-host;$W=$H.ui.rawui;$B=$W.buffersize;$B.width=%3;$B.height=%4;$W.buffersize=$B;}" GOTO:EOF
Posted 14 February 2016 - 01:12 PM
This was nothing than an idea in hope it could be somehow implemented.
Again, I never worked with this kind of menu. Therefore I'm not able to assist.
Sorry for intruding your thread.
Posted 14 February 2016 - 01:22 PM
set OPT="This is the First" Second Third Fourth Fifth "666 66" "777 777" 888 999 10101 111 1212 %* set OPT=!OPT:%OPT%=%* exit!(not that it would make any noticeable difference)
Posted 14 February 2016 - 01:59 PM
This was nothing than an idea in hope it could be somehow implemented.
Again, I never worked with this kind of menu. Therefore I'm not able to assist.
Sorry for intruding your thread.
Posted 15 February 2016 - 08:32 AM
I wrote quite a few of my own helper functions. They provide you a StrLen.exe which you don't really need. You can still determine the length of a string in batch alone, I've done it before with my own callable section of a batch script using batch substrings.
Looks like a nice solution was created throughout this thread though
0 members, 0 guests, 0 anonymous users