# CodeGuru Technical FAQs > CodeGuru Individual Visual Basic FAQs >  AttachThreadInput

## TT(n)

Normally, each thread in the system has its own input queue. This function allows threads and processes to share input 'queues. Focus, window activation, mouse capture, keyboard state, and input queue status are shared when threads are 'attached, allowing related input functions to work as in Win16.



```
    Private Declare Function apiAttachThreadInput Lib "user32" Alias "AttachThreadInput" (ByVal idThreadAttach As Int32, ByVal idThreadAttachTo As Int32, ByVal fAttach As Int32) As Int32
    Private Declare Function apiGetCurrentThreadId Lib "kernel32" Alias "GetCurrentThreadId" () As Int32
    Private Declare Function apiGetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (ByVal hWnd As Int32, ByRef lpdwProcessId As Int32) As Int32
    Private Function AttatchInput(ByVal hWnd As Int32, Optional ByVal bAttatch As Boolean = True) As Boolean
        Return CBool(apiAttachThreadInput(apiGetWindowThreadProcessId(hWnd, 0), apiGetCurrentThreadId, CInt(bAttatch)))
    End Function
```

----------

