How can I find whether focus is actually in the document?

A

AnthonyHall

I have a Word template that needs to capture keystrokes and format the
text in certain paragraph types. For example it needs to change
letters to italic and numbers to plain.

I am trying to do this by capturing hooking keystrokes with a CBT hook
and then looking to see whether the selection is in a particular
style. The problem is that keystrokes don't always end up in the
document itself. I can check that they are not going to a dialog box
by GetForeground window, I can check that they are not going into a
comments pane using selection.active, and I can check that they aren't
going into mail headers with application.FocusInMailHeader. However
that still leaves the possibility that they are going to a task pane -
for example document properties - or a control on the ribbon or QAT or
a commandbar in pre 2007 versions.

Is there any way I can check for these other possibilities?

(Just to forestall the obvious question - yes, I have also considered
doing this completely differently, by binding the keys to macros. In
fact that's how the template works currently. But it has its own huge
raft of problems)

Thanks for any help

Anthony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top