beyond.wudge has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I'm a newbie to Linux and to Perl. I have half of a degree so far in software engineering and have spent a few years helping out at a small business, learning the basics of IT support. I have an input problem related to key presses executing custom code -- like a numpad key moving the mouse instead of sending a character message.

I already have a script that:

imports Win32::GuiTest

declares configuration variables

loops
{
if statement that checks for ( IsKeyPressed(numpad virtual key) ) then SendMouseMoveRel(arguments)
}

This produces the first part of the requirement -- the mouse does move with the press of a key. However, the key still sends a message to the OS. Does Perl or a module within Perl possess a function that can specifically block or intercept a key press? I understand that a hook may be required, but I'd rather try something higher level first.

I'm developing this for both Microsoft Windows 7 and 10 and on Linux distros including Unity. I'm intending this for use both within work and home environments, at a small business and on my own desktop and laptops.

Regards,

beyond.wudge

Replies are listed 'Best First'.
Re: Replacing keyboard functionality
by shmem (Chancellor) on Apr 23, 2018 at 02:18 UTC

    /dev/null is a container of vast proportions. More than pseudo-code is required to prevent your request from being sent thither.

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
      I see, so you can redirect output in Linux to a 'null' device, which then does not output it. But that would be the same as using a hook because I'd have to override the distro's default procedure for handling key presses.

      Also, it's OS specific. I'm sure that someone has needed to implement a higher level solution for work environments featuring a mix of Linux and non-Linux environments.
Re: Replacing keyboard functionality
by Anonymous Monk on Apr 23, 2018 at 17:06 UTC

    Windows and Linux/X11 both already have support for Accessibility Features. See Mouse keys.

      I tried mouse keys originally and found it wasn't configurable enough. I also want to emulate more than 3 button mice, or add other functions to the numpad that aren't just duplicating a mouse input -- as you might do with a logitech gaming mouse.