KeyFake    NLM to push characters into file server keyboard buffer.
           Freeware written by Wolfgang Schreiber

Purpose:   Automize keyboard entries for other NLMs

Syntax:    LOAD KeyFake <parameters>

           The character '!' will be converted into a <cr>

Example:   LOAD KEYFAKE Unload TimeSync!y!

           In this sample KEYFAKE will push the string 
           "Unload TimeSync<cr>y<cr>" into the servers keyboard buffer.

Prerequisites:
           NetWare v3.1x/v4.0x or higher. On NetWare v3.11 you will 
           need an updated CLIB available on NetWire, otherwise you 
           will receive the error message "Loader cannot find public 
           symbol ..." when loading Keyfake.



Source code:

#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <conio.h>
#include <process.h>
#include <string.h>


void main(int argc, char **argv)
{
   char line[255];
   int  i;
   int  consoleScreen;

   SetAutoScreenDestructionMode(TRUE);
   consoleScreen = GetCurrentScreen();
   DestroyScreen(consoleScreen);

   consoleScreen = CreateScreen("System Console", 0);
   SetCurrentScreen(consoleScreen);

   if (argc>0)
      {
      strcpy(line, "");
      for (i=1; i<argc; i++)
          {
          strcat(line, argv[i]);
          strcat(line, " ");
          }
      line[strlen(line)-1] = '\0';
      }


   for (i=0; i<strlen(line); i++)
       {
       if (line[i] == '!') line[i] = '\r';
       ungetch(line[i]);
       if ((i % 10)==0) delay(10);
       }
}