Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2005

Tip: Looking for answers? Try searching our database.

Determining Thread Id

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tbannist - 26 Apr 2005 21:08 GMT
Ok, so I've got my keyboard hook code working except for one problem, it
currently hooks all keystrokes not just the ones destined for Word.  It looks
like I need to determine the threadId for Word or the currently active
document window to create a local hook, however, I can't seem to find any
properties that will give me a threadId or even a window handle(wHnd) so I
can get the threadId.

Any suggestions on how to figure out what the thread id of Word is?
Jonathan West - 27 Apr 2005 00:06 GMT
You can get the Window handle by using the FindWindow or GetActiveWindow API
calls.

There are plenty of VB code samples on the web tat use one or other of these
API calls. A google search will find them. So long as the code is not
VB.NET, it should drop into a VBA project more or less unmodified.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

> Ok, so I've got my keyboard hook code working except for one problem, it
> currently hooks all keystrokes not just the ones destined for Word.  It
[quoted text clipped - 5 lines]
>
> Any suggestions on how to figure out what the thread id of Word is?
tbannist - 28 Apr 2005 16:58 GMT
> You can get the Window handle by using the FindWindow or GetActiveWindow
> API calls.

Thanks, it turns out it wasn't the thread id that was the problem, for some
reason, I can't hook WH_KEYBOARD_LL on the Word thread, but I can hook
WH_KEYBOARD.  Fortunately, WH_KEYBOARD is good enough for me.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.