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 / January 2008

Tip: Looking for answers? Try searching our database.

Get Word Window Handle?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Julian - 21 Jan 2008 17:34 GMT
I have some useful code (incl declarations into user32) for checking
keyboard events but it needs Word's Window Handle (Word 2002) - Excel 2002
has Application.hWnd but there's nothing like that for Word alas.

Anyone know how to do this in VBA? (example would be apreciated)

Thanks

Julian

Signature

Julian I-Do-Stuff

Some Vista stuff, but mostly just Stuff at http://berossus,blogspot.com

Shauna Kelly - 22 Jan 2008 03:54 GMT
Hi Julian

At the top of the module, add the following:
Private Declare Function FindWindowByClass Lib "user32" _
   Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName
As Long) As Long

When you want the handle, use

Dim lngHWnd as long

lngHWnd  = FindWindowByClass("opusapp", 0&)

FWIW, "Opus" was the code name for the first version of Word for
Windows.

Hope this helps.

Shauna Kelly.  Microsoft MVP.
http://www.shaunakelly.com/word

>I have some useful code (incl declarations into user32) for checking
>keyboard events but it needs Word's Window Handle (Word 2002) - Excel
[quoted text clipped - 5 lines]
>
> Julian
Julian - 22 Jan 2008 08:43 GMT
Thanks Shauna - just what I was looking for!

I'd found something similar elsewhere but was missing the lpClassName,
which, as you demonstrated, was somewhat arbitrary (not like "XLMAIN")

Haven't tried it yet but it looks like it will do the trick perfectly - then
I will be able to do the auto-saving I want *only* when Word is idle...

VMT! Julian

Signature

Julian I-Do-Stuff

Some Vista stuff, but mostly just Stuff at http://berossus,blogspot.com

> Hi Julian
>
[quoted text clipped - 25 lines]
>>
>> Julian
Julian - 22 Jan 2008 12:52 GMT
Hi Shauna

That works nicely, but I've just realised I may have been asking the wrong
question (it's certainly harder to debug with this approach!)

What I want to do is to trap keyboard events so that I can note the time of
the last keypress...

any suggestions?

Signature

Julian I-Do-Stuff

Some Vista stuff, but mostly just Stuff at http://berossus,blogspot.com

> Hi Julian
>
[quoted text clipped - 25 lines]
>>
>> Julian
Jonathan West - 22 Jan 2008 14:23 GMT
> Hi Shauna
>
[quoted text clipped - 5 lines]
>
> any suggestions?

It sounds like you are trying to write a keylogger. Many such have already
been written, many of them open-source. Just do a web search for
"keylogger".

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

 
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.