Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. press any key to continue

press any key to continue

Scheduled Pinned Locked Moved Visual Basic
csharpquestion
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nadroj
    wrote on last edited by
    #1

    regarding vb.net console apps... i was wondering if there was a way to determine when any key was pressed? so it can be used for instances where a 'press any key to continue' type of thing is necessary, or where a one character answer is required. Thx. ------------------------ Jordan. III

    D 1 Reply Last reply
    0
    • N Nadroj

      regarding vb.net console apps... i was wondering if there was a way to determine when any key was pressed? so it can be used for instances where a 'press any key to continue' type of thing is necessary, or where a one character answer is required. Thx. ------------------------ Jordan. III

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Check into Console.Read() or Console.ReadLine(). RageInTheMachine9532

      N 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Check into Console.Read() or Console.ReadLine(). RageInTheMachine9532

        N Offline
        N Offline
        Nadroj
        wrote on last edited by
        #3

        thanks iv already worked with .read() and .readline(). .readline() gets input from the console. the user must press enter key to end the input. .read() is just like .readline but it doesnt read the full line of text the user entered, if it was even a full line at all. in both cases. the user must press the -enter- key. is there away to do it without having to press enter? ------------------------ Jordan. III

        D 1 Reply Last reply
        0
        • N Nadroj

          thanks iv already worked with .read() and .readline(). .readline() gets input from the console. the user must press enter key to end the input. .read() is just like .readline but it doesnt read the full line of text the user entered, if it was even a full line at all. in both cases. the user must press the -enter- key. is there away to do it without having to press enter? ------------------------ Jordan. III

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          OK. The Console class doesn't support the type of input that you want, ... yet. You'd have to look at the Win32 API to get what you want. Specifically, the GetConsole, GetStdHandle, GetConsoleMode, SetConsoleMode, FlushConsoleInputBuffer, and ReadConsoleInput functions. You'd have to write your own PressAnyKey function that, when entered into, gets the handle to the current console window, get the handle to the StdIn stream, saves the current console input mode on the stream, setups up a new mode that disables LINE INPUT, then use FluchConsoleInputBuffer to clear out any remaining keystrokes. Put up your 'Press any key to continue' prompt, then use ReadConsoleInput to get the next character in the input stream. When all that is done, then you restore the console input mode and call FlushConsoleInputBuffer to clear any remain keystrokes out. Hopefully(!), this functionality will be in .NET 2.0. RageInTheMachine9532

          N 1 Reply Last reply
          0
          • D Dave Kreskowiak

            OK. The Console class doesn't support the type of input that you want, ... yet. You'd have to look at the Win32 API to get what you want. Specifically, the GetConsole, GetStdHandle, GetConsoleMode, SetConsoleMode, FlushConsoleInputBuffer, and ReadConsoleInput functions. You'd have to write your own PressAnyKey function that, when entered into, gets the handle to the current console window, get the handle to the StdIn stream, saves the current console input mode on the stream, setups up a new mode that disables LINE INPUT, then use FluchConsoleInputBuffer to clear out any remaining keystrokes. Put up your 'Press any key to continue' prompt, then use ReadConsoleInput to get the next character in the input stream. When all that is done, then you restore the console input mode and call FlushConsoleInputBuffer to clear any remain keystrokes out. Hopefully(!), this functionality will be in .NET 2.0. RageInTheMachine9532

            N Offline
            N Offline
            Nadroj
            wrote on last edited by
            #5

            Wow.. sure looks like you did some homework, either online or previously, in your head. ill try and check it out! thanks alot Dave ------------------------ Jordan. III

            D 1 Reply Last reply
            0
            • N Nadroj

              Wow.. sure looks like you did some homework, either online or previously, in your head. ill try and check it out! thanks alot Dave ------------------------ Jordan. III

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              Most of it from memory, but a little research on MSDN for the specifics... Who knows...if I get the time, I might make a class out of it and write up a CodeProject article. :-D RageInTheMachine9532

              N 1 Reply Last reply
              0
              • D Dave Kreskowiak

                Most of it from memory, but a little research on MSDN for the specifics... Who knows...if I get the time, I might make a class out of it and write up a CodeProject article. :-D RageInTheMachine9532

                N Offline
                N Offline
                Nadroj
                wrote on last edited by
                #7

                :omg::eek::-D well ill be sure to hold you to it.. ------------------------ Jordan. III

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups