In an abbreviated sense, here is the order of processing for any input:
1.Hardware device detects input and interrupts the processor
2.Hardware input gets queued.
3.A user mode thread wakes up and gets the next raw hardware event (in a time ordered manner)
4.The user mode thread does some quick checks to determine which application should get the input.
5.The input is put in the appropriate thread input queue. The thread owning the queue is woken up if necessary.
6.The thread reads the input out of the message queue. The thread determines which window it goes to. It creates the finished product – a window message.
7.The window message is returned back to the application, the application processes the input.
Although abbreviated, this is the normal sequence for input processing under Win32. Any application can have multiple threads. Each thread potentially has a message queue associated with it (as mentioned in the section on `multiple threads of execution'). These threads can read input out of their input queues in a leisurely manner without affecting the performance of any other app or thread and without affecting the user's ability to redirect input to any other window.