Input from the keyboard - inportb() / outportb() - C language! RRS feed

  • Question

  • So...

    I am working on a hotkeys program for Windows (using The C Program Language), in which I need to get input directly from the keyboard - Not from the console. Since C is a dead language it took me forever... but eventually (!!!) , I figured out I can use inportb() and outportb() functions to read and write data from the input ports.

    So I tried this solution... nope. Those functions are included in <dos.h>, And the compiler can't find such a directory.. I am using GCC as a compiler.

    does anyone know where can I get this library from or how can I overcome this problem using other functions or libraries..?

    Saturday, June 3, 2017 5:28 PM

All replies

  • You can use a WH_KEYBOARD_LL hook

    Saturday, June 3, 2017 8:39 PM
  • Is there a reason the standard keyboard management in Windows won't work for you?  There is a lot of information starting from this page:

    Saturday, June 3, 2017 10:16 PM
  • The header dos.h is, as the name implies, for the DOS operating system. The dos.h header won't work in Windows just as the header windows.h won't work in Linux.

    Both Linux and Windows are multi-processing systems. They support use of multiple resources. Peripheral devices, such as keyboard, the monitor and disk drives are shared resources. An important purpose of multi-processing operating systems is to allow resources to be shared. You must get keyboard input from Windows. There are some functions unique to console programs but other than that most functions are available to all Windows programs (but the world is becoming complicated so there are exceptions). So as IoTGirl indicates, it is important that you explain why you think the regular Windows functions won't work.

    Sam Hobbs

    Monday, June 5, 2017 3:29 AM
  • I don't understand why people reply to someone who is also trying to help with a reply for the person asking the question. Usually it is obvious but if people do that too much then there will be times when people get confused. So in other words, you are replying to Castorix31 but the reply is for 1324Mip1324, right?

    Sam Hobbs

    Monday, June 5, 2017 3:39 AM