// $Revision: 1.3 $ // Copyright (c) 1994-1995 Taligent, Inc. All rights reserved. #ifndef TaligentSamples_KEYCLICKER #include "KeyClicker.h" #endif #ifndef IOSTREAM #include #endif #ifndef Taligent_CLOCK #include #endif void main() { // This input system class will receive events from attached input devices, and // distribute them to registered targets. TStandardEventReceiver* receiver = new TStandardEventReceiver(); // This is our class which we want to handle key events. TKeyClicker clicker; // Register our class with the receiver. It will distribute key events to us. clicker.RegisterSimpleTarget(*receiver); // Ok, we're ready. Start the thread that will receive input events and pass them to // our receiver. It will adopt the receiver, and delete it when the (last) handle dies. TEventReceiverHandle receiverHandle(receiver); // You have 20 seconds to type. Our clicker will receive the keys as long as our // receiver has the user focus. If it loses the user focus (say, if you click the // mouse on an object such as a window which grabs the user focus) you'll just have // to wait until we time out. cout << "Start typing, you have 20 seconds..." << endl; TSystemClock().DelayFor(TSeconds(20)); cout << "That's all folks!" << endl; }