Chapter 18. WH_CBT

You use the WH_CBT hook primarily for building Computer Based Training (CBT) applications. A CBT application trains a user to use an application. Usually, it will present a text-based set of instructions for using the application; however, it also can contain multimedia demonstrations. But the real power of CBT is its ability to walk the user through specific pieces of the application in which the user is being trained. The real magic behind CBT is the WH_CBT hook, although you can typically use other hooks as well, including the WH_JOURNALPLAYBACK hook and the WH_MOUSE and WH_KEYBOARD hooks.

Let’s step through a portion of an example CBT application -- in this case, a simple one in which the user is learning how to save an Excel spreadsheet. When the CBT application starts an Excel application and opens a sample spreadsheet, it gathers some general information about the application that will tell it what the user is doing in Excel, including:

  • The ProcessID

  • The handle to the top-level window

  • The handle to the main menu

  • The position of the top-level window

Next, the application presents the user with instructions on how to save a spreadsheet, possibly including a multimedia presentation as well. After reading the explanation, the user is prompted to perform the Save operation on the running instance of Excel. This is where the WH_CBT hook comes into play: the hook is installed before the user actually performs the Save operation and is released after the user is finished ...

Get Subclassing and Hooking with Visual Basic now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.