home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cenvi23.zip / KEYPUSH.CMD < prev    next >
OS/2 REXX Batch file  |  1994-10-03  |  3KB  |  72 lines

  1. EXTPROC CEnvi2
  2. /*************************************************************************
  3.  *** KeyPush.cmd - Quick interface to pass KeyPush commands directly.  ***
  4.  *** ver.1         This program temporarily activates the window, does ***
  5.  ***               its stuff, then restores window.                    ***
  6.  *************************************************************************/
  7.  
  8. #include <PMdll.lib>
  9. #include <WinTools.lib>
  10.  
  11. main(argc,argv)
  12. {
  13.    if ( argc < 3  ||  !strcmp(argv[1],"/?")  ||  !strcmpi(argv[1],"help") )
  14.       Instructions();
  15.    else {
  16.       // Append all of the input into a long string
  17.       Code = "";
  18.       for ( i = 2; i < argc; i++ ) {
  19.          strcat(Code," ");
  20.          strcat(Code,argv[i]);
  21.       }
  22.  
  23.       // save the currently active window to be restored
  24.       RemememberActiveWindow = GetActiveWindow();
  25.  
  26.       // Set the active window to First argument
  27.       if ( stricmp("NULL",argv[1])  &&  !SetActiveWindow(argv[1]) ) {
  28.          printf("Unrecognized Window Title \"%s\"\n\a",argv[1]);
  29.          exit(EXIT_FAILURE);
  30.       }
  31.  
  32.       ExecuteKeyPushCode(Code);
  33.  
  34.       // Restore currently active window
  35.       if ( stricmp("NULL",argv[1]) )
  36.          SetActiveWindow(RemememberActiveWindow);
  37.    }
  38. }
  39.  
  40.  
  41. ExecuteKeyPushCode(CodeString)
  42. {
  43.    system("CEnvi2 \"#include \'KeyPush.lib\'%s \"",CodeString);
  44. }
  45.  
  46. Instructions()
  47. {
  48.    printf("\n")
  49.    printf("   KeyPush - Quick commands to the KeyPush.lib functions\n")
  50.    printf("\n")
  51.    printf("   SYNTAX: KeyPush WinTitle KeyPushCode...\n")
  52.    printf("\n")
  53.    printf("   Where: WinTitle - Name of a window; use NULL for currently active window\n")
  54.    printf("                     If not NULL then switches to this window for commands.\n")
  55.    printf("          KeyPushCode - Any code from the KeyPush.lib library.  Read\n")
  56.    printf("                        KeyPush.lib for all the functions and codes.\n")
  57.    printf("                        Strings must be enclosed in SINGLE QUOTES (\')\n");
  58.    printf("\n")
  59.    printf("   Example: This examples selects the second from smallest DOS font\n")
  60.    printf("     KeyPush \"DOS Window\" KeyStroke(VK_ALT); KeyStroke('F');\n")
  61.    printf("     KeyStroke(VK_HOME); KeyStroke(VK_DOWN); KeyStroke(VK_ENTER);\n")
  62.    printf("\n")
  63.    printf("   Example: This examples mimics all the keystrokes to lockup screen\n")
  64.    printf("     KeyPush \"Desktop\" KeyStroke(VK_CTRL,'\\\\');\n")
  65.    printf("     KeyStroke(VK_SHIFT,VK_F10); KeyStroke('L');\n")
  66.    printf("\n")
  67.    printf("   Example: These two examples write \"doggy\" to the E.EXE editor\n")
  68.    printf("     KeyPush E.EXE KeyStroke(\'doggy\');\n")
  69.    printf("     KeyPush E.EXE SpeedKeys(\'doggy\');\n")
  70. }
  71.  
  72.