3.1. The Example Application

I created my first, roughly 300-line Windows program for this report that demonstrates many of the core principles behind screen reading. The program prints out, for all of the other programs and their controls, the class and window text on keyboard focus change. In addition, the program recoggnizes button types and states and can react to button state changes. Further more, the program follows selection changes in the menus. Even if it doesn't really have a model about the current screen contents, the basics of building such a model are shown by a function traversing all the direct children of an activated window. The source code, in its entirety, is shown in appendix a. The user interface in the program receives the least attention on purpose. That is, my goal was to make a passable GUI with a minimal amount of code

Due to the amount of code in the example program, it's not fully covered in the text but we'll rather concentrate on hooks here. First a brief explanation of the main program, though. The main program (syshook.cpp) creates a simple window containing a text field in which it prints out the messages received from hooklib.dll. The hooks themselves are set up with the function hooklibInitialize at program startup and removed by a function named hooklibCleanup when the program is ended. The message handling in the window procedure is pretty mundane. Window size and focus changes are forwarded to the text field whose the only child of the main window. Handling the message WM_COPYDATA will be explained in the section about dynamic link libraries.

Back to the Contents