Tom R. Valdez
Nov 8th, 1999, 05:40 AM
Can anyone tell me how to obtain the threadID for the main window of a foreign application? I need to disable keyboard input temporarily so that the user doesn't interfere with an automated process. I've done this in the past for the current application, but now one of our projects has the requirement that I replace a portion of a data entry application's user interface with a customized form and I need to disallow user keyboard input to the data entry application while still allowing mouse input to it during a period when I'm directing keyboard input to my custom form.
I'm working in VB and know how to lock and unlock kybd input for a particular thread using WinAPI calls as follows:
Dim hHook As Long
'disable keyboard input
hHook = SetWindowsHookEx(WH_KEYBOARD, AddressOf KeyboardProc, 0&, ThreadID)
'Do something while keyboard is disabled
'enable keyboard input
Call UnhookWindowsHookEx(hHook)
where KeyboardProc is a callback routine that I've coded to throw out the keyboard input.
The problem is with ThreadID. I can get this to work for an app which I've written (in VB I can use App.ThreadID), but I can't figure out how to get the threadID for a foreign application's main window. I've spent hours querying the Win32 SDK references and MSDN trying to find a way to get a threadID. All I can find are variations of FindWindow (which returns a window handle, not the threadID) along with various methods of obtaining threadIDs for the application one is coding.
Any ideas would be greatly appreciated, thanks!
------------------
Tom R. Valdez
Senior Analyst
General Networks Corp.
tomv@gennet.com
818-249-1962 Ext. 743
I'm working in VB and know how to lock and unlock kybd input for a particular thread using WinAPI calls as follows:
Dim hHook As Long
'disable keyboard input
hHook = SetWindowsHookEx(WH_KEYBOARD, AddressOf KeyboardProc, 0&, ThreadID)
'Do something while keyboard is disabled
'enable keyboard input
Call UnhookWindowsHookEx(hHook)
where KeyboardProc is a callback routine that I've coded to throw out the keyboard input.
The problem is with ThreadID. I can get this to work for an app which I've written (in VB I can use App.ThreadID), but I can't figure out how to get the threadID for a foreign application's main window. I've spent hours querying the Win32 SDK references and MSDN trying to find a way to get a threadID. All I can find are variations of FindWindow (which returns a window handle, not the threadID) along with various methods of obtaining threadIDs for the application one is coding.
Any ideas would be greatly appreciated, thanks!
------------------
Tom R. Valdez
Senior Analyst
General Networks Corp.
tomv@gennet.com
818-249-1962 Ext. 743