Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- FUNCky - <b>name:</b> <b>mousetrap() - use mouse to stuff keys into keyboard buffer</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  Name:     mousetrap() - use mouse to stuff keys into keyboard buffer
  Usage:    mousetrap(<function>,<key>) or:
            mousetrap(<function>,<up>,<down>,<left>,<right>)
  Params:   integer <function> - mouse function that invokes stuffing
            of the <key> into the buffer. A <0> means on the left
            button press, a <1> means on the right button press, a <2>
            means on a middle button press (on a PC mouse) and a <3>
            means whenever the mouse is moved. (see below).

            integer <key> - key to stuff into the buffer whenever the
            action defined by <function> takes place.

            This is known as 'baiting the trap'. Once the trap is baited, use
            the m_trapset() function to 'set the trap'. Once the trap is set,
            any event you have defined will cause the appropriate key to
            be stuffed. Use SET KEY TO or the timeout() function to
            cause popup functions to be mouse driven while in wait states.

            If you define the <function> as <3> (mouse movement),
            then you must define 4 (four) key values to stuff. One to be
            stuffed on mouse movement upwards, one on downwards, as
            well as to the left and right. This is useful to simulate cursor
            movement based on mouse movement. If you do not want a
            mouse movement to stuff a keystroke, then define the <key>
            as a <0> (zero). Params are as follows if the mouse function
            is 3:

            <function>     - mouse movement function (3)
            int <up>       - key to stuff on movement upwards
            int <down>     - key to stuff on movement downwards
            int <left>     - key to stuff on movement to the left
            int <right>    - key to stuff on movement to the right

  Returns:  nothing

 ---------------------------------- Example ---------------------------------

                 m_trapnew()
                 * start with a clean state

                 * bait the mousetrap()

                 mousetrap(0,28)
                 * sets up the left button as F1

                 mousetrap(1,27)
                 * sets up the right button as ESCape

                 mousetrap(3,5,24,19,4)
                 * sets the up/down/left/right movements equal
                 * to the equivalent cursor keys.

                 m_trapset()
                 * set the mouse trap so that keys are active

                 memvar = space(20)
                 @ 10,0 say "Enter Data:" get memvar
                 read

                 m_trapfree()
                 * release the trap so no keys are stuffed
                 * when we don't want them

            * The user can now use the mouse to navigate
            * somewhat inside the read. The left button can bring up
            * help and the right button will ESCape. Mouse
            * movement will move the cursor.

  Warning:  If you have set a mousetrap(), you MUST use m_trapfree()
            before you RUN any external programs. If the mousetrap
            remains in effect outside of your Clipper program your
            computer will hang if you cause a mouse event that you are
            trapping. Do not call mousetrap() initially from an overlay.
            Loading a new overlay could cause the mousetrap code to be
            swapped out. If a mouse event occurs that you are trapping,
            a system hang could occur if the mousetrap code has been
            swapped out of memory.


See Also: m_trapset() m_trapfree() m_trapnew() m_trapsave()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson