Novell is now a part of Micro Focus

StuffKey Utility 1

Novell Cool Solutions: Cool Tool

Digg This - Slashdot This

In Brief

Send keystrokes to any program on any screen.


Product Categories:
  • NetWare
  • Functional Categories:
  • Server Utilities
  • Posted:10 Sep 2002
    File Size:35KB


    Please read the note from our friends in legal before using this file.


    STUFFKEY.NLM allows you to send keystrokes to any program on any screen. This gives you to ability to automate processes that require user input.

    Installation Instructions

    Copy STUFFKEY.NLM to the SYS:\SYSTEM directory on your server.

    NOTE: 3.12 servers require CLIB 3.12l or greater and CLIBAUX.NLM.
        4.10 servers require CLIB 4.11o or greater
        4.11 servers require service pack 5 or greater

        If the above requirements are not met, Stuffkey may not be able to load because of unresolved symbols.



        stuffkey [CommandFile [options]] [/?]

    For help do:

        load stuffkey ? | /?

    Product Description

    STUFFKEY.NLM allows you to send keystrokes to any program on any screen. This gives you to ability to automate processes that require user input.

    USAGE: stuffkey [CommandFile [options]] [/?]

        CommandFile = Full pathname of command file (See Examples)
        Options = preface option(s) with '-' or '/' (eg -sv)
           d=n - Delay n milliseconds between characters
           s - do not view target Screens during execution
           r - Return to original screen when completed
           v - Verbose mode (shows progress on console)
           ? - Display help message

       Allows keystrokes to be passed to another screen.

    StuffKey uses a command file which contains the screen name on the first line on which to issue the keystrokes. All successive lines contain either plain text or tokens representing special keys. Note that Newline characters in the file are ignored; the <CR> token must be used if a newline character is to be sent to the screen.

    A default intercharacter delay of 50 milliseconds is used unless it is overridden with the /d switch.

    Command File:
       The first uncommented line of the command file contains the initial screen name (case insensitive). The <SCREEN=xxx> token is used to specify the initial screen.

    All successive lines contain text and tokens consisting of printable ASCII characters. All non-token characters are taken literally. Imbedded newline characters in the file are ignored. Newlines (Enter) are sent to the screen using the <CR> token.

    Comments are marked by # or ; as the first character of the line. To specify a \ or < preface it with a \.

    Syntax: <[count] token | \x>
          Where x can be any ASCII character
    - All tokens are enclosed in <>.  - The first characters of any token can be a repeat count, which will repeat that token value or character n times. Literal characters can be repeated using the \x format.
    - Tokens are case-insensitive

    PAUSE (used with count to pause playback n msec.)
       for example <5000 pause> will pause for 5 secs
    LOG NEW|APPEND=LogFilePath
       Open a log file in preparation for the DUMP token.
       NEW will create or destroy an existing log,
       APPEND will create or append to an existing log.
       The full NetWare path and filename should be specified; Only DOS filenames (8.3 format) are supported.
       Dump the current screen to the log file
       Switch to ScreenName as current screen.
       Stuffkey will terminate if ScreenName doesn't exist.
       Wait for ScreenName to be available and make it current
       Wait for ScreenName to become unavailable (removed) and default to System Console as the current screen
       Wait for Any Text to appear within the current screen

    A timeout in minutes can be specified before WAITFOR
    (default is 2 minutes)
    example: <5 WAITFOR Text=Enter Login Name>
    (Wait for 5 minutes for the text to appear)

    Unmodified Keys:
    Shifted Keys:
    Control Sequences:
    Alt Sequences:
       ADASH, AEQ, ALTA...ALTZ, AF1...AF10, A0...A9

    Known Issues/Problems:
       CPGUP & CPGDN will not work in the C-Worthy (NUT) user interface. CPGDN is treated like CR.
       CPGUP is simply invalid.

    When you close out the current screen by exiting the application that owns it, you must switch to a known good screen before executing any further commands that will attempt to output any characters, otherwise the OS will return Invalid Screen ID errors.
    Use the <SCREEN=xxx> or <WAITFOR SCREEN=xxx> tokens to switch to another screen.

    Running Stuffkey Examples:

       load stuffkey sys:cmds/fixall.txt /v
       (execute commands in sys:cmds/fixall.txt in verbose mode)

       load stuffkey /s
       (execute and don't display any target screens)

       load stuffkey /d=5
       (execute with 5ms intercharacter delay)

    Example Command Files:

    Example 1: (Load and navigate an NLM's Screen)
       # Load DSREPAIR and Repair local DS database
       # Start at the console screen and load dsrepair
       <screen=System Console>
       load dsrepair<cr>
       # Wait for the dsrepair screen to be created and make it current
       <waitfor screen=dsrepair status screen>
       # Go to Advanced options menu in dsrepair
       # Go to Repair local DS database menu option
       # Set option to Exit automatically and execute

    Example 2: (Waiting for NLMs to unload)
       # Unload NLMs in sequence
       # Go to an NLM's screen and exit from it
        <screen=Web Server Screen>
       # Waitfor the NLM's screen to terminate
       <waitfor noscreen=web server screen>
        # The screen is now gone and we are at the system console
        # screen. We can now unload its library
       unload weblib<cr>
       <waitfor text=module weblib.nlm unloaded>

    Example 3: (Waiting for screens and text)
       # Load oracle and login to the database
       <screen=System Console>
        # Start Oracle
       # wait for the oraconfig screen
       <waitfor screen=oracle configuration screen
       # Login option is down 2 items in the menu
       # Wait for the prompt
       <waitfor text=login name>

    Example 4: (Logging)
       # Gather configuration information
       <screen=System Console>
       # Open a new log file (remove it if it already exists)
       <log new=sys:etc/sklog.txt>
       # Get configuration information from the server
       # Dump the screen to the log to capture the information
       # Just in case there's more, press Enter to get the last page
        # Dump the screen again to the log file to get any new info

    Enhancements/Bug Fixes

    Beta 0.01
    - First Release
    Beta 0.02
    - Added SCREEN token to enable switching to other screens
    Beta 0.03
    - Added ability to load it multiple times
    - It now reports the script name in "completed" message1.00
    - Removed from beta status to general release
    - Failed to find screen if screen name had trailing spaces
    - Allow screen token as initial screen name since many were confused about that two ways to specify screens.
    - PGDN token is now recognized
    - Allow spaces after a repeat number <nnnn token>
    - Added <waitfor noscreen=xxx> token
    - Added <LOG> and <DUMP> tokens
    - Doc clarification and added samples

    Known Issues

    Issue 1:
    CPGUP and CPGDN do not work in the C-Worthy (NUT) user interface. CPGDN is treated like CR, CPGUP is simply invalid.

    Issue 2:
    When you close out the current screen by exiting the application that owns it, you must switch to a known good screen before executing any further commands, otherwise stuffkey will return an Invalid Screen ID error. It's always safe to switch to System Console.

    Frequently Asked Questions

    Q: Is there a recording feature to record my keystrokes?
    A: Not currently. Building the command file is a manual process.

    Q: Is there a limit to the size of the command file?
    A: No.

    Q: Can I specify multiple screens in one command file? Often I need to switch to multiple screens such as when I am automating SBACKUP.
    A: Yes, you specify new screens with the SCREEN token anywhere within the script. It's also handy to use the <waitfor screen=xxx> token to wait for a screen to be created before switching to its screen.

    Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions.

    © Copyright Micro Focus or one of its affiliates