Switching the switching of Keys!



I recently lamented about switching two keys on my new Lenovo Yoga. Big problem: In my office, I attach that notebook to a docking station and to that docking station I attach a keyboard. On that keyboard, all keys are precisely the way I want them to be. Therefore, I do not want to switch the Insert and End keys when I am docked. I ended up writing a little batch script based on this nice google code wiki entry for the registry update and this stackexchange answer to elevate the batch script:
@ECHO OFF
NET FILE 1>NUL 2>NUL
if '%ERRORLEVEL%' == '0' goto run 
powershell "saps -filepath %0 -verb runas" >nul 2>&1
goto eof
:run
REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout" ^
 /v "Scancode Map" >nul 2>&1 
IF '%ERRORLEVEL%' == '0' goto remove
<nul set /p ="> adding scancode map "
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout" ^
 /v "Scancode Map" /t REG_BINARY /f ^
 /d 00000000000000000300000052E04FE04FE052E000000000 >nul 2>&1 
IF '%ERRORLEVEL%' == '0' goto success
goto fail 
:remove
<nul set /p ="> removing scancode map "
REG DELETE "HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout" ^
 /v "Scancode Map" /f >nul 2>&1 
IF '%ERRORLEVEL%' == '0' goto success
goto fail
:fail 
echo failed.
pause
goto eof
:success
echo succeeded.
pause
Sadly, it always requires a reboot for the changes to take effect.

5 Replies to “Switching the switching of Keys!”

  1. You do know about MSKLC[0], right? Build your own custom layout and install it as a regular Windows keyboard layout. No registry tweaks, no reboot required. [0] -- http://www.microsoft.com/en-us/download/details.aspx?id=21476
  2. I knew it was a good idea to link the old site here, it lured clever people over. And no, I had no idea about the Microsoft Keyboard Layout Creator. I will have a look. It will work, and this post will seem mighty silly.
  3. No problem for that, really. Were you the guy who emailed me about putting the archives back? Didn't associate the name with that nick ;). Anyway, I now remember that I actually did try the MKLC, but it does not work on newer versions of Windows =(.
    1. Nope, I wasn't the guy that mailed you about the archives. I haven't had the chance to run Windows 8 yet but it seems some guys0 are able to use MKLC 1.4 on it. You could also build the kit on a Windows 7 machine and then try to install it on your laptop. If I understand correctly if you have .NET 2.0 it should work anywhere. 0 http://answers.microsoft.com/en-us/windows/forum/windows_8-winapps/msklc-microsoft-keyboard-layout-creator-for/a54a4db0-94c0-4f08-8909-37a7c5b758bb

Leave a Reply

Your email address will not be published.