kbhit()

This is a discussion on kbhit() within the Windows Programming forums, part of the Platform Specific Boards category; hi every time i try to use kbhit() i get an EAccessViolation whats wrong with it?...

  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,786
    Its undefined and should not be used.....

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

    im checking out your kb-hooking tutorial on your hp. maby the use of a dll may be the right thing im 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,786
    Originally posted by wesentlich
    aha.
    and what else should be used?

    im checking out your kb-hooking tutorial on your hp. maby the use of a dll may be the right thing im 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,825
    > 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,786
    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 loling around in my tread

    cant 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,786
    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,786
    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. im not running this as a console.

  14. #14
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    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

    ill work on it tomorrow.

    thanx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 11-30-2007, 08: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, 04: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21