PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

Allow to remap complex keyboard events (macros)

Open antonioyon opened this issue 4 years ago • 12 comments

Keyboard Manager should allow mapping complex keyboard events in Key and Mapped To parameters

Currently, the keyboard manager allows for remapping of simple keyboard events, such as single key-down, to a different keyboard event, which may include multiple modifiers (Ctrl, Shift, Alt). It would be a benefit to allow input parameters to be complex keyboard events including modifiers (Ctrl), multiple key events (holding down Shift (Left) and Shift (Right)), and key-up events (mapping Ctrl (Left) to be Ctrl on key-down and Esc on key-up).

The specific use-case I want to see is to replicate an AutoHotKey script that modifies the Caps Lock to Ctrl when pressed with another key, so Caps Lock - V would sendCtrl - V, but to send Esc on key-up if no other key is pressed. Additionally, the script also maps Shift (Left) and Shift (Right) combo to send Caps Lock.


If you'd like to see this feature implemented, add a 👍 reaction to this post.

antonioyon avatar Aug 05 '20 16:08 antonioyon

The use case is related to #5679 @crutkas @saahmedm is this something we plan to support in the future? I think having complex events on the left column would be problematic (something that works better with stuff like AHK scripts). For complex events in the right column I feel it would be like an "Advanced mode" which allows custom macros where you would be able to "Type" and the sequence of key strokes will be detected and used (rather than just the keys as we do now). This would be sort of similar to the macro feature in the Microsoft Mouse & Keyboard Center, but that can only be done for programmable keys on certain keyboards.

Regarding the specific use case mentioned above I elaborated on it in #5679.

arjunbalgovind avatar Aug 06 '20 00:08 arjunbalgovind

In terms of implementation, the challenges would be figuring out a UI for this. Microsoft Keyboard & Mouse Center has an interesting UI which seems like the best way that it can be presented to the user without requiring actual "scripts". In terms of implementation, we would need to monitor an input sequence of events, and whenever that exact sequence occurs we would send the output events. MKCMacro

arjunbalgovind avatar Oct 30 '20 20:10 arjunbalgovind

Removing the KBM label since this goes far beyond the scope of KBM. KBM should remain a simple straightforward tool to do what is supposed to do. There are several enhancement suggested for the KBM that hopefully we will do in the future, but this particular suggestion is not about remapping existing shortcut, but about providing extended macro functionality similarly to AutoHotKey .

enricogior avatar Feb 05 '21 07:02 enricogior

In terms of implementation, the challenges would be figuring out a UI for this. Microsoft Keyboard & Mouse Center has an interesting UI which seems like the best way that it can be presented to the user without requiring actual "scripts". In terms of implementation, we would need to monitor an input sequence of events, and whenever that exact sequence occurs we would send the output events. MKCMacro

It looks nice but also can any key on say, my keyboard(except power button) be remapped/used as macro keys, that would be really awesome as some of the keys on my keyboard have no function at all so it'd be nice to remap them to a shortcut or a macro!

0-BlackSpectrum-0 avatar Oct 13 '21 15:10 0-BlackSpectrum-0

Hello any progress requarding this toppic ?

GamerClassN7 avatar May 03 '22 15:05 GamerClassN7

This feature would make my life considerably easier. Use cases:

  • add a non-breaking space anywhere with a shortcut for ALT+0160
  • add an endash to documents without having to type ALT+0150
  • typing characters such as ñ (ALT+0241) with an US keyboard layout
  • add a ™ to a product name without having to memorize ALT+0153

I wouldn't mind copying and pasting the specific character from charmap into PowerToys.

moatmai avatar May 06 '22 14:05 moatmai

@moatmai Check it out: https://ilyabirman.net/typography-layout/

VladWinner avatar Jun 10 '22 00:06 VladWinner

Noob-workaround for the time beeing:

  1. place a shortcut for your script (i.e. vbs) on your desktop
  2. Set a normal Keyboard-shortcut via context-menu -> properties i.e. [CTRL]+[ALT]+[SHIFT]+[F12]
  3. in powertoys keyboard manager, remap that combo to something you want

(this will make it possible to run the script on F16-F19 for example)

YeonV avatar Aug 08 '22 08:08 YeonV

AutoHotkey could do this without breaking a sweat!

Jay-o-Way avatar Aug 08 '22 09:08 Jay-o-Way

Is this feature ever going to be implemented or not? I'm just saying because this issue has been open for more than 2 years now and its status is still up in the air. I think many would appreciate it if we had a definite answer to this question. Thanks.

theerfan avatar Nov 03 '22 19:11 theerfan

@theerfan have you tried MS Mouse & Keyboard app or AutoHotkey yet?

Jay-o-Way avatar Nov 08 '22 15:11 Jay-o-Way

@theerfan have you tried MS Mouse & Keyboard app or AutoHotkey yet?

I am using AutoHotKey, I was just wondering if it was ever going to be implemented here as well. :D

theerfan avatar Nov 16 '22 05:11 theerfan

Switch default audio device on windows with keyboard shortcut.

shushilchaurasiya avatar Dec 09 '22 12:12 shushilchaurasiya

https://www.youtube.com/watch?v=--cHILkVUtw Power Automate in the Microsoft Store So, do we really need to keep this open?

Jay-o-Way avatar Jan 08 '23 01:01 Jay-o-Way

So, do we really need to keep this open?

A number of contributors have suggested to use a different app to solve the issue. IMO that doesn't really address the issue itself: a request to extend PowerToys functionality.

I, for one, am just looking for a way to map special characters, preferrably using Unicode values which you can paste from the Character Map (charmap), in Keyboard Manager.

moatmai avatar Jan 09 '23 12:01 moatmai

I agree fully with this comment of moatmai ...

A number of contributors have suggested to use a different app to solve the issue. IMO that doesn't really address the issue itself: a request to extend PowerToys functionality.

WGEM-U avatar Jan 09 '23 13:01 WGEM-U

Perhaps something that can call/create power automate functions from within powertoys could be handy.

Im all for reducing blat and multiple programs doing the same thing. But it seems like a bit of a hastle to use 40 diferent Guis. Perhaps some sort of gui added to power toys that calls power automate without having to run expensive gui overhead.

And it also seems pointless to have key binds that can't handle combinations. (Note, i’m no longer on Windows )

NicTanghe avatar Mar 01 '23 21:03 NicTanghe

To add my voice, another use case is to map combination of keys to events: For example, CTRL+DOWN to volume down, CTRL+UP to volume up (because my keyboard does not have media keys).

khaf avatar Mar 19 '23 15:03 khaf

I'd like to request this macro functionality as well. Extremely useful.

shevros avatar Apr 10 '23 20:04 shevros

So is it already possible to make an assignment for Ctrl+A and Ctrl+C so that that keypress simultaneously selects everything and copies it?

jczanfona avatar Jul 14 '23 17:07 jczanfona

So, do we really need to keep this open?

A number of contributors have suggested to use a different app to solve the issue. IMO that doesn't really address the issue itself: a request to extend PowerToys functionality.

I, for one, am just looking for a way to map special characters, preferrably using Unicode values which you can paste from the Character Map (charmap), in Keyboard Manager.

This issue has grown to encapsulate multiple different kinds of requests that honestly should be categorized differently:

Should be implemented

  • Missing Characters from Key Remapper due to not being able to map keys the existing keyboard doesn't have including multilingual and media keys

Should be debated

  • Character -> String Mapping (Ex: A -> {shift}this{space}is{space}a{space}sentence{!}{enter})
  • Context Aware Key Remapping (Ex: A -> Q in Excel Only)
  • Sequence of Characters -> Different Sequence of Characters (Ex: IDK -> I don't know)

Would best be a plugin

  • Character -> Mouse/Other Input
  • Character -> Program Execution
  • PowerAutomate Integration
  • Managing Audio Devices (Excluding Volume Up/Volume Down/Mute for Default Audio Device)
  • AutoIt / AHK Integration

I've been tackling the plugin-esque features myself in a side project that registers a URI but I think I'll try creating a plugin tomorrow for some basic stuff by borrowing most of @skttl 's ptguid plugin code.

Linking with PowerAutomate should be easy as it has its own registered URI.

Additionally, I can add in AutoIt (the parent of AHK) and probably AHK functionality.

This shouldn't be anything complex to make into a plugin as I'm just punting the input off to PowerAutomate/AutoIt/AHK.

However, I've never started a C# project from scratch, let alone compiled it (to a dll even!) so this will be a fun learning experience.

rcmaehl avatar Aug 13 '23 17:08 rcmaehl

I just got myself a MS 3050 keyboard and mouse. As @arjunbalgovind showed earlier, the Mouse and Keyboard Center app allows you to set a huge number of functions to a lot of keys. Both on the mouse and the keyboard. Both "basic" and "app-specific settings". It's really awesome!

Perhaps something that can call/create power automate functions from within powertoys could be handy.

🤔💭Thinking of a PT Run plug-in... wdyt @htcfreek ?

Jay-o-Way avatar Feb 01 '24 14:02 Jay-o-Way

🤔💭Thinking of a PT Run plug-in... wdyt @htcfreek

@rcmaehl nade something like this.

htcfreek avatar Feb 01 '24 15:02 htcfreek

Window 11 has this functionality basically built in:

  1. Go to C:\Users\«your name»\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
  2. Right click, New, Shortcut to get the new shortcut dialog
  3. Type wt for Windows Terminal and click Next
  4. If you like, change the name to Terminal and click Finish (Note: the actual shortcut won't be actually shown on your taskbar)
  5. Open the properties for the shortcut you just created (Alt+Enter)
  6. On the tab "shortcut"in "shortcut key" press Ctrl+Alt+T
  7. Click Apply

Test it by pressing Ctrl+Alt+T

realbart avatar Feb 02 '24 23:02 realbart