randyrants / sharpkeys

SharpKeys is a utility that manages a Registry key that allows Windows to remap one key to any other key.
http://www.randyrants.com/
Microsoft Public License
6.15k stars 409 forks source link

Question: Can Sharpkeys be used as a CLI #576

Closed carlitorendon closed 2 weeks ago

carlitorendon commented 4 weeks ago

Amazing program, love it.

I handle multiple keymaps for different scenarios. Was thinking about automating the switching of key bundles. I know I still have to log out and log back in but I was thinking on writing a little script to avoid having to use the UI every time.

I played with the executable with /? to probe it. Just checking if this is possible?

DreymaR commented 4 weeks ago

For such an application though, do you really require the robustness of registry remapping – which as you know, comes with the clunkiness of same?

I use my AutoHotKey-based EPKL program for my multi-keymap/layer needs. It's really very powerful and satisfying.

https://dreymar.colemak.org (select the Windows icon)

carlitorendon commented 3 weeks ago

Thank you for recommending this @DreymaR. I have skimmed through it and has a lot of potential. Will definitely bookmark it

randyrants commented 3 weeks ago

Likewise, my additional recommendation would be that once you have a keyset saved to the Registry, you can export the Key/Value out to a .reg file and call that whenever you need that specific set. For example, I use the same remapping on my laptops, so I exported that as a REG file. When I reinstall Windows, I just run the REG file rather than using SharpKeys.

DreymaR commented 3 weeks ago

I just thought about that, actually: Is there a handy how-to on how to do that? It's been a while since I was last seen messing about with RegEdit! No small thanks to SharpKeys, as you may well imagine.

carlitorendon commented 3 weeks ago

@DreymaR just export all the registry stuff from SharpKeys and save it in a file with extension .reg. Then run it like this:

reg import "path\to\file.reg"

DreymaR commented 3 weeks ago

How do I export from SharpKeys? Do you mean writing to the Registry then saving the changes? If so, how?

A SharpKeys .skl save file is not in a .reg compatible format, as far as I can see.

I just realized: Would it be nice if SharpKeys had the option to export a mapping scheme as .reg directly?

randyrants commented 3 weeks ago

I explicitly opted to stay out coding import and export Registry functions because the Registry Editor already has the "best in class" import/export functionality for itself.

  1. Open regedit.exe with admin privileges.
  2. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout
  3. Right click on Keyboard Layout and select Export.
  4. Give it a filename that ends with .REG
  5. Open the .REG file in Notepad and remove any extra stuff that went into the REG file except for what looks like this: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] "Scancode Map"=hex:00,00,00,00,00,00,00,00,0d,00,00,00,4f,e0,44,00,49,e0,57,00,\ 51,e0,58,00,37,e0,42,00,47,e0,43,00,00,00,3a,00,44,00,4f,e0,43,00,47,e0,58,\ 00,51,e0,57,00,49,e0,42,00,37,e0,5b,e0,38,e0,00,00,00,00
  6. Save the file.

At this point, you can drop this onto any PC, double-click it to import it to that PC, and reboot.

randyrants commented 3 weeks ago

Alternatively, for steps 1-4 above: a. Open a command prompt with admin privledges b. Run this command: reg export "HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout" [some_filename].reg c. Open the .REG file in Notepad and remove any extra stuff that went into the REG file except for what looks like this: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] "Scancode Map"=hex:00,00,00,00,00,00,00,00,0d,00,00,00,4f,e0,44,00,49,e0,57,00,\ 51,e0,58,00,37,e0,42,00,47,e0,43,00,00,00,3a,00,44,00,4f,e0,43,00,47,e0,58,\ 00,51,e0,57,00,49,e0,42,00,37,e0,5b,e0,38,e0,00,00,00,00 d. Save the file.

DreymaR commented 3 weeks ago

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout

See, here's where the dog lies buried! To you, navigating to that key is probably second nature. Ten years ago I'd have remembered it too, but now I was chanceless. And there are a lot of keys in there!

So, new proposal: Could SharpKeys help us near-dementia users over that hurdle by either: 1) Having a button that opens RegEdit at this key (actually sounds very cool and handy!) 2) Having a button that runs your reg export ... command (more direct result, but I'd prefer option 1)

The rest of your helpful tips above could be mentioned in a popup window or something.

carlitorendon commented 2 weeks ago

Thank you @randyrants for clarifying.