AminetAminet
Search:
84506 packages online
About
Recent
Browse
Search
Upload
Setup
Services

util/batch/KeyPressed.lha

Mirror:Random
Showing:m68k-amigaosppc-amigaosppc-morphosi386-arosi386-amithlonppc-warpupppc-powerupgeneric
No screenshot available
Short:Check if keys are pressed (for scripts)
Author:zodiac at darkness.gun.de (Ralph Seichter)
Uploader:zodiac darkness gun de
Type:util/batch
Architecture:m68k-amigaos
Date:1995-09-03
Download:http://aminet.net/util/batch/KeyPressed.lha - View contents
Readme:http://aminet.net/util/batch/KeyPressed.readme
Downloads:1010

   This tool checks if at least one key of a given list of keys is pressed
and delivers an appropriate return code, which can be processed in shell
scripts to trigger any action you like.

   To give you an idea of what "KeyPressed" can do for you, imagine that
you have three different startup-sequences around. Number 1 is the one for
everyday use, the standard startup. Number 2 and 3 are optimized versions
for special applications. When you want to execute number 2 or 3 on bootup,
you could boot once without a startup-sequence, then copy the desired file
over your standard startup (make sure to backup Number 1 first), and then
reboot your Amiga. Does this sound inconvenient? It is.

   "KeyPressed" will help you out of your misery. Include the following
lines somewhere at the beginning of your S:startup-sequence (your standard
startup file) and copy "KeyPressed" to your C: directory or elsewehere in
your command path.

        KeyPressed 64
        IF WARN
            ; KeyPressed reports that the space bar (raw key code 64)
            ; was pressed. Execute alternate startup-sequence number 2.
            Execute S:startup-sequence.2
            EndCLI >NIL:
            Quit
        ENDIF

        KeyPressed 96 97 99
        IF WARN
            ; The control key (raw key code 99), the left shift key (96)
            ; or the right shift key (97) was pressed. Execute alternate
            ; startup-sequence number 3.
            Execute S:startup-sequence.3
            EndCLI >NIL:
            Quit
        ENDIF

   As you can see, "KeyPressed" requires a list of decimal raw key codes.
You can supply as many codes as you wish, but as there is only a fixed
number of keys on a keyboard, there is a natural limit implied. :)

"KeyPressed" will return the code 5 (RETURN_WARN) if at least one of the
specified key was pressed, and otherwise 0 (RETURN_OK) is returned. Please
Note that raw key codes are *DIFFERENT* from ASCII codes. Here is a list of
selected codes common to all Amiga models:

        Key name                Code
        Space bar               64
        Enter (numeric keypad)  67
        Return                  68
        F1 - F10                80 - 89
        Help                    95

   For a complete list of the Amiga's raw key codes, please have a look at
the ROM Kernel Reference Manual "Devices" (section "console.device").


Contents of util/batch/KeyPressed.lha
 PERMSSN    UID  GID    PACKED    SIZE  RATIO     CRC       STAMP          NAME
---------- ----------- ------- ------- ------ ---------- ------------ -------------
[generic]                  550     664  82.8% -lh5- eb01 Aug 30  1995 KeyPressed/KeyPressed
[generic]                 1594    3430  46.5% -lh5- 9eca Aug 30  1995 KeyPressed/KeyPressed.doc
---------- ----------- ------- ------- ------ ---------- ------------ -------------
 Total         2 files    2144    4094  52.4%            Sep  3  1995

Aminet © 1992-2024 Urban Müller and the Aminet team. Aminet contact address: <aminetaminet net>