NET to "listen" to an office application (get user-raised events)

I am on the verge of reinstalling my e-learning app. But now I want to take this new version to the next level.

So this is the scenario: the user opens my application. Then he chooses to study in one of the most common MS Office applications (Word, Excel, Outlook, etc.).

My app will provide instructions for the user on what to do: create a new document, type text, make it bold, insert a picture, etc. If done correctly, the user will receive points. If not, decrease it.

But (always is), but for me it is necessary so that I can "see" what the user is doing. I am using NET (2.0 - C # or VB, it doesn't matter which). Can anyone tell me how to do this? I need to get a handle to an open Office application or start a new one and then I have to listen and evaluate everything the user does. If the user does it wrong, I also need to send instructions to the Office application and do it for him / her.

Is it possible? Does anyone have any code examples on how to do this or something similar?

Thanks in advance

PS: I really don't want Office to add to accomplish this!

Edited: The reason I don't want to get into VBA is because I wanted to make sure it can be reused to help users use other applications further down the road. So I wanted to somehow create a listener for the application and decode the interaction with it.

0


a source to share


2 answers


There is actually a Windows hook designed for computer learning applications called WH_CBT and it provides notification when windows are activated, minimized, moved, changed, commands, mouse / keyboard events, etc.

I won't lie to you, but binding is quite a complex topic, but certainly available for .NET. Check out the following MSDN article which explains how to use message binding in .NET, then look at the two links that follow for more information on WH_CBT.

Cutting Edge: Windows Hooks in the .NET Framework



MSDN Library: SetWindowsHookEx Function

MSDN Library: CBTProc Function

+1


a source


The Office Automation API is a COM API. You can call it from managed (.NET) code, but that just adds an extra layer and makes things that much more complex. I've done a great job of automating Office using VB / VBA and C #, and while I love C # as a language, I have to say that it is much more difficult to manage this way. Much. (It's easy to get it to work on your machine at least once, but don't let that fool you.)

The API allows you to capture specific events like menu selections, control panel button clicks, window activation, document opening / closing, etc. You can also catch a "fetch changed" event, which in theory can be used to determine what the user is doing. But there are many direct manipulation tasks that the user can perform to prevent you from catching a trap (e.g. drag with the mouse, resize the image, etc.), and for your purposes I would say it is a big problem.



I have to say that I highly doubt that you will be able to do what you suggest, at least not well enough to make it smooth. And I would think it should be explosion-proof enough given your user base.

Unfortunately.: - (

+2


a source







All Articles