// KeyGhost.cmm - Example for how to control other programs using the // the keyboard stuffing routines in KeyPush.Lib. #include #include #include // Start NotePad running if ( -1 == spawn(P_NOWAIT,"NotePad.exe") ) { MessageBox("ERROR: Unable to execute NotePad.exe."); exit(1); } // Enter initial CEnvi sentence SpeedKeys("CEnvi is good."); // Change "good" to "great" for ( i = 0; i < 5; i++ ) KeyStroke(VK_SHIFT,VK_LEFT) SpeedKeys("great!"); // Figure out how much it costs per day for a year SpeedKeys("\n\nIs it worth 38 dollars?\n" "To use it every day for a year costs"); // Bring up calculator to figure $38.00 / 365 * 10 if ( -1 == spawn(P_NOWAIT,"Calc.exe") ) { MessageBox("ERROR: Unable to execute Calc.exe."); exit(1); } SpeedKeys("C38.00/365=*100=",300);// perform calculation KeyStroke(VK_ALT,"EC"); // copy result into the clipboard KeyStroke(VK_ALT,VK_F4); // Exit the calculator // Paste the result into NotePad then continue senctence KeyStroke(VK_ALT,"EP"); SpeedKeys(" pennies a day.\nWhat a bargain!"); // now print the message to register SpeedKeys("\n\nRegister now!"); // copy the Register message just printed and print it many more times KeyStroke(VK_SHIFT,VK_HOME); KeyStroke(VK_SHIFT,VK_UP); KeyStroke(VK_CONTROL,VK_INSERT); KeyStroke(VK_DOWN), KeyStroke(VK_END); // print that message another 15 times for ( i = 0; i < 7; i++ ) KeyStroke(VK_SHIFT,VK_INSERT); // finally, say goodbye and exit SpeedKeys("\nThank you."); KeyStroke(VK_ALT,"FXN");