ModemJunki Posted January 27, 2017 Share Posted January 27, 2017 I'm not sure if this can actually be done. I'd like to make a console application that outputs a prompt and then waits for user to input a single key and then acts on it while ignoring other keys (beep at the user if they are pressed), like choice.exe does in batch files. I started out just trying to get ConsoleRead() to accept a single key press as input but I can't figure out how to get it to accept a key without the user pressing enter. The below (simplified) code captures the user input but it requires enter to be pressed. Can single-key input read be done with ConsoleRead() as I describe? #AutoIt3Wrapper_Change2CUI=y $s_input = "" ConsoleWrite("Input? ") Do $s_input = ConsoleRead() If @error Then ContinueLoop If @extended <> "" Then ExitLoop Until $s_input <> "" Always carry a towel. Link to comment Share on other sites More sharing options...
RTFC Posted January 27, 2017 Share Posted January 27, 2017 (edited) I would suggest you use HotkeySet instead, or (if you want your hotkey response to be window-specific) embed your console in a gui (example, example) and use GUIsetAccelerators. Edited January 27, 2017 by RTFC typo My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
ModemJunki Posted January 27, 2017 Author Share Posted January 27, 2017 Thanks, RTFC. I'm doing this to help someone maintain some old batch files they want to re-use for a 64-bit Windows PE environment (where choice.exe has no direct replacement and using "set /p" requires the extra keypress of an enter key). My initial preference was to re-write the batch files with an AutoIT GUI but then I would be stuck maintaining them. I will try to build something for them with HotKeySet if I can find the time, else they have to use "set /p" for now. Always carry a towel. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now