I am building an application program in C++ which uses Windows hooks to control third-party programs. The program I am making is a tutorial program to show how to use these third-party programs. I can find the process ID of the third-party program that I want to hook into and I can then query this process ID to find a list of thread IDs to use as a parameter for the Windows API function SetWindowsHookEx. However I am concerned that from the list of thread IDs from the running process I will hook into a thread that could potentially finish at any moment. Ideally I would like to hook into the thread running the main gui which is more than likely going to be one of the longest living threads (and even if it isn't the longest living thread the tutorial program is designed to work with the GUI so it is still ideal). If the third-party application has more than one gui then I would like to find the thread ID for the main GUI.
So my question is from the list of thread IDs I get from querying the process id is there a way to find either the main GUI id or another suitable thread which will be active until the program has quit? Obviously the thread ID that I choose needs to have an event queue so I can hook into it.