Thread: kbhit()

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    37

    kbhit()

    hi

    every time i try to use kbhit()
    i get an EAccessViolation
    whats wrong with it?

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Its undefined and should not be used.....

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    37
    aha.
    and what else should be used?

    i´m checking out your kb-hooking tutorial on your hp. maby the use of a dll may be the right thing i´m looking for.

    is there a simple way to check key-entry on win32?

    ps.: by the way... i found a t-shirt with the same cool transformers-sign in a store:-))))

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by wesentlich
    aha.
    and what else should be used?

    i´m checking out your kb-hooking tutorial on your hp. maby the use of a dll may be the right thing i´m looking for.

    is there a simple way to check key-entry on win32?

    ps.: by the way... i found a t-shirt with the same cool transformers-sign in a store:-))))
    Jeez...this function is popular today...here

    BTW....One day I might get the decepticon sign tatooed on my arm....now that would be a cool tatoo......

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    37
    wow. nice little function...
    thanx

    <<BTW....One day I might get the decepticon sign tatooed on my arm....now that would be a cool tatoo......

    and turn bad forever.....aaaaahahahahahahaha

  6. #6
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    > BTW....One day I might get the decepticon sign tatooed on my arm....now that would be a cool tatoo......

    Remember, Fordy - having a lame tattoo does NOT make you Petzold, no matter what you may think

  7. #7
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by Govtcheez
    > BTW....One day I might get the decepticon sign tatooed on my arm....now that would be a cool tatoo......

    Remember, Fordy - having a lame tattoo does NOT make you Petzold, no matter what you may think

    LOL

  8. #8
    Registered User
    Join Date
    Sep 2001
    Posts
    37
    stop lol´ing around in my tread

    can´t get your kbhit function running.

    allways have a error in ReadConsoleInput(hIn,&ip,1,&dwResult)
    error 6 (with GetLastError)... whatever that wants to tell me

    looked at msdn, but the code looks allright.
    there must be something i have forgotten.

  9. #9
    Registered User
    Join Date
    Sep 2001
    Posts
    37
    ok. it wants to tell me that the handle is invalid.
    what i have made is...

    Code:
    HANDLE hIn ;
    DWORD dwResult;
    INPUT_RECORD ip;
    
    
    void __fastcall TForm1::Timer1Timer(TObject *Sender)
    {
    
    hIn = GetStdHandle(STD_INPUT_HANDLE);
    
       if (hIn==INVALID_HANDLE_VALUE)
          Edit1->Text="invalid...";
    
       if(!ReadConsoleInput(hIn,&ip,1,&dwResult))
          Edit1->Text=GetLastError();//Get event
    
       if(ip.EventType == KEY_EVENT)//Is it keyboard?
          Edit1->Text="gnuf";
    }
    what can i do to get the "gnuf" in my edit-box??

  10. #10
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Hmm...you are running this as a console right?

  11. #11
    Registered User
    Join Date
    Sep 2001
    Posts
    37
    if console means a win-application... (this funny windows on my screen )... yes.
    excuse my disknowledge.

  12. #12
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    A console is the dos emulator.........the black char based screen that uses int main(void).......

    If you are doing this in a full blown windows app than it wont work

  13. #13
    Registered User
    Join Date
    Sep 2001
    Posts
    37
    oh. i should have known this.

    no. i´m not running this as a console.

  14. #14
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    If this is a window program....you need to filter the WM_KEYDOWN or WM_KEYUP.....

  15. #15
    Registered User
    Join Date
    Sep 2001
    Posts
    37
    aha

    i´ll work on it tomorrow.

    thanx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 11-30-2007, 09:46 AM
  2. kbhit() for enter key? not working
    By yahn in forum C++ Programming
    Replies: 4
    Last Post: 04-03-2006, 02:44 AM
  3. implicit declaration of int kbhit(...);
    By Blizzarddog in forum C++ Programming
    Replies: 14
    Last Post: 11-13-2003, 05:39 PM
  4. Pausing for input, with kbhit() still detecting keys
    By Da-Spit in forum C++ Programming
    Replies: 5
    Last Post: 05-23-2002, 05:04 AM
  5. need more help on kbhit()
    By lordvlaad() in forum C++ Programming
    Replies: 0
    Last Post: 04-20-2002, 02:07 AM