Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Remapping Keyboard on Win32

by gryphon (Abbot)
on Mar 23, 2006 at 03:15 UTC ( #538644=perlquestion: print w/replies, xml ) Need Help??
gryphon has asked for the wisdom of the Perl Monks concerning the following question:

Greetings all,

I recently had wrist surgery on my right wrist to remove a gamglion cyst and other problems with the joint. The surgery was a success, and things are healing well, but I'm stuck in a cast-like thing for at least another two weeks, likely longer. This makes typing with both hands all but impossible. (Yes, I'm typing this message with one hand.) I started Googling and found out about one-handed keyboards like this and this, and that got me thinking: couldn't I just do the same thing with Perl?

I use both Windows and Linux at work and at home, but most of the typing I need to do over the next couple weeks is in Word on Windows, so while I'd love a solution that works on both platforms, I'm biased toward a Win32 solution. I started looking into Win32::API a bit, and then I wandered down the rabbit hole of C# by reading this keyboard hook example. I also searched around on PerlMonks and found code to activate and deactivate the keyboard.

Has anyone else tied this? Am I wandering in the right direction? Is there an easier solution? Thanks very much.

gryphon Development Manager (WDDC)
code('Perl') || die;

Replies are listed 'Best First'.
Re: Remapping Keyboard on Win32
by zentara (Archbishop) on Mar 23, 2006 at 12:33 UTC
Re: Remapping Keyboard on Win32
by gryphon (Abbot) on Mar 24, 2006 at 17:22 UTC

    Greetings all,

    The bad news is that I haven't been able to solve this problem yet. The good news is that my wrist is healing much faster than expected, and I'm now in a smaller splint that frees up my right hand for typing. So I'm abandoning this effort; however, just in case someone else wants to work on this in the future, here's the code I ended up with:

    I primarily used this example along with Win32::API. Although I'm not seeing any errors, I don't think I'm getting the keyboard hook set correctly because $n never increments no matter how many keys I hit while the script runs. The $get_key_state call works just fine, but I can't seem get $callback to get called on keypress. Oh well.

    gryphon Development Manager (WDDC)
    code('Perl') || die;

      Again, in case someone else ends up here, you might want to check out the Scan Code Mapper for Windows. Basically, you add a registry key saying what keys you want to remap. Its simpler than writing anything if your requirements are straightforward. Night

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://538644]
Approved by jfroebe
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2017-09-23 04:54 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (270 votes). Check out past polls.