microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
110.73k stars 6.52k forks source link

[KBM] Add a hotkey key to turn it on/off #4879

Open ghost opened 4 years ago

ghost commented 4 years ago

A way in which to easily toggle on and off the keyboard manager feature without having to leave fullscreen apps, specifically games.

A shortcut keybind that is resignable that would allow for the keyboard manager to be toggled on and off without the need to alt+tab out of games.

A resign-able shortcut key to toggle keyboard manager. This is for those of us out there who game, having an easy to access way to toggle the keyboard from alt setups to default qwerty for WASD would be great. At the moment I need to alt+tab and manually click the feature off and on and it is very cumbersome. I had a previous setup with a custom keyboard and portable keyboard layout, but there was always the odd app that would choose the wrong keyboard, so powertoys is better, but the toggle would be a huge help.

StuartKent17 commented 4 years ago

Another option could be a right click context menu on the taskbar icon? Here just because I use the powertoy to switch L-WIN and L-ALT for a Mac keyboard.

ghost commented 4 years ago

Another option could be a right click context menu on the taskbar icon? Here just because I use the powertoy to switch L-WIN and L-ALT for a Mac keyboard.

I guess that would be fine for anyone who is not using an exclusive fullscreen app such as games.

arjunbalgovind commented 3 years ago

@crutkas, this wouldn't be very difficult to implement, but it might require us to always keep the KBM hook active (rather than unhooking on disable). We can't use a separate hook as we need to make sure the "Toggle shortcut/key" is unaffected by remaps.

albertorm95 commented 1 year ago

Any updates?

tcdongjun commented 1 year ago

any updates ?

oOWestmalleOo commented 1 year ago

Hello, I see that there are a lot of requests on this subject and that apparently things aren't progressing very well, so I was wondering if there might be a workaround. For example, modify a registry key to enable Keyboard manager and then automate the change. Or create a PowerToys launch shortcut with a launch option to enable or disable Keyboard manager. Or any other way you can think of. What do you think?

Ps : Sorry for my English, but I'm French

tcdongjun commented 1 year ago

please~

tcdongjun commented 1 year ago

It’s a real joke that the Keyboard Manager cannot be toggled on or off using keyboard shortcuts.

Cheizr commented 1 year ago

Hi, any update on this? It's frustrating that i need to enable or disable the keyboard administrator with my mouse

Meukbox commented 10 months ago

This look like a great solution for remapping keys in a game, but there HAS to be a fast way to toggle it on or of in case you need to just type some text, like chatting with a team mate.

Snipes89 commented 10 months ago

Please add this, It should be a shortcut keys of your choice to enable and disable the Keyboard Manager. There has been quite a few updates but this hasn't been added

peyao commented 10 months ago

Since there's now a "PowerToys" plugin in PowerToys Run, perhaps adding a toggle Keyboard Manager On/Off integration into that plugin would be useful and make a lot of people here happy.

For example, Win+Space to open PowerToys Run, type "@" to filter PowerToys options and select "Keyboard Manager" to toggle it on/off. This is quicker than opening PowerToys UI itself and going through the menus to toggle KBM.

I imagine that works around the issue of "keeping the kbm hook active" for a global hotkey.

mattpang commented 9 months ago

I did something like this as powershell script to toggle if the process is running or not, then just made a powershell icon on the desktop. Then you can probably keybind something to run that with autohotkeys:

`$km = Get-Process PowerToys.KeyboardManagerEngine

if ($km) { Stop-Process -Name PowerToys.KeyboardManagerEngine } else { Start-Process -FilePath 'C:\Users\USERNAME\AppData\Local\PowerToys\KeyboardManagerEngine\PowerToys.KeyboardManagerEngine.exe' }`

nuomation commented 8 months ago

I did something like this as powershell script to toggle if the process is running or not, then just made a powershell icon on the desktop. Then you can probably keybind something to run that with autohotkeys:

`$km = Get-Process PowerToys.KeyboardManagerEngine

if ($km) { Stop-Process -Name PowerToys.KeyboardManagerEngine } else { Start-Process -FilePath 'C:\Users\USERNAME\AppData\Local\PowerToys\KeyboardManagerEngine\PowerToys.KeyboardManagerEngine.exe' }`

Hi there, seems like this is the solution I have been waiting for, even tho I am not a developer I know basic coding, how can I run this script with power toys?

SceptreData commented 8 months ago

I did not intend to learn so much about powershell today, but boy what an adventure. Here's my little script to toggle KBM + trigger notification to show whether its now on or off. At the bottom of this post I include instructions for using the script with a keyboard hotkey (no autohotkey).

thanks to @mattpang for getting me started here:

Did this on Windows 11, make sure your execution policy will allow you to run local scripts without signing. You can do that through the settings app here: image

Next, install BurntToast , which simplifies notifications from Powershell.

#  Install BurntToast for notifications
Install-Module -Name BurntToast

The script

$kbm = Get-Process PowerToys.KeyboardManagerEngine -ErrorAction SilentlyContinue

if ($kbm){
    Stop-Process -Name PowerToys.KeyboardManagerEngine
    New-BurntToastNotification -Text 'Powertoys Keyboard Manager DISABLED'
} else {
    Start-Process -FilePath 'C:\Program Files\PowerToys\KeyboardManagerEngine\PowerToys.KeyboardManagerEngine.exe'
    New-BurntToastNotification -Text 'Powertoys Keyboard Manager ENABLED'
}

Using with a keyboard shortcut:

Create a shortcut on your desktop (ugh...) From properties, set target to: pwsh -WindowStyle Hidden -file "C:\path\to\my\script.ps1" If you're using something older than powershell 7, replace pwsh with powershell.exe.

Set a shortcut key to whatever you want (I'm using Ctrl + Alt + K).

Then set the shortcut to "Run:"in Minimized window. This should stop a terminal window from opening up when you use the shortcut.

Using this confuses the Power Toys dashboard, it seems to lose track of whether or not KeyboardManager is running, but that hasn't been an issue so far.

nuomation commented 7 months ago

I appreciate the guide! Thanks a lot

mbybtjh commented 6 months ago

I did not intend to learn so much about powershell today, but boy what an adventure. Here's my little script to toggle KBM + trigger notification to show whether its now on or off. At the bottom of this post I include instructions for using the script with a keyboard hotkey (no autohotkey).

thanks to @mattpang for getting me started here:

Did this on Windows 11, make sure your execution policy will allow you to run local scripts without signing. You can do that through the settings app here: image

Next, install BurntToast , which simplifies notifications from Powershell.

#  Install BurntToast for notifications
Install-Module -Name BurntToast

The script

$kbm = Get-Process PowerToys.KeyboardManagerEngine -ErrorAction SilentlyContinue

if ($kbm){
    Stop-Process -Name PowerToys.KeyboardManagerEngine
    New-BurntToastNotification -Text 'Powertoys Keyboard Manager DISABLED'
} else {
    Start-Process -FilePath 'C:\Program Files\PowerToys\KeyboardManagerEngine\PowerToys.KeyboardManagerEngine.exe'
    New-BurntToastNotification -Text 'Powertoys Keyboard Manager ENABLED'
}

Using with a keyboard shortcut:

Create a shortcut on your desktop (ugh...) From properties, set target to: pwsh -WindowStyle Hidden -file "C:\path\to\my\script.ps1" If you're using something older than powershell 7, replace pwsh with powershell.exe.

Set a shortcut key to whatever you want (I'm using Ctrl + Alt + K).

Then set the shortcut to "Run:"in Minimized window. This should stop a terminal window from opening up when you use the shortcut.

Using this confuses the Power Toys dashboard, it seems to lose track of whether or not KeyboardManager is running, but that hasn't been an issue so far.

这个方法是可行的,但是有一点需要注意。Windows默认下是无法运行powershell脚本的,需要手动设置才行。按下win键,输入powershell,右键点击,以管理员身份运行powershell。输入set-executionpolicy remotesigned,接着输入y,然后就可以运行powershell脚本了。

DigitalHype commented 4 months ago

@crutkas, this wouldn't be very difficult to implement, but it might require us to always keep the KBM hook active (rather than unhooking on disable). We can't use a separate hook as we need to make sure the "Toggle shortcut/key" is unaffected by remaps.

To workaround around this bootstrapping issue, you could link the proposed feature to the enabling and disabling of remappings instead of the entire Keyboard Manager module. This would achieve the desired result of restoring default mappings via a keyboard shortcut. Provide a user option to enable this feature and assign a meta shortcut (e.g. RCtrl+PgDn) that is not mappable when this feature is enabled via a configuration option.

Jay-o-Way commented 3 months ago

Quoting @halcyon101...

I have written a vbs code that does this, please just add it to the app here is the code:

Set objShell = CreateObject("WScript.Shell")

' Check if Keyboard Manager is running
Set objWMIService = GetObject("winmgmts:\.\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'PowerToys.KeyboardManagerEngine.exe'")

If colProcessList.Count > 0 Then
' If running, stop the process
For Each objProcess in colProcessList
objProcess.Terminate()
Next
Else
' If not running, start the process
objShell.Run """C:\Program Files\PowerToys\KeyboardManagerEngine\PowerToys.KeyboardManagerEngine.exe""", 0
End If

https://github.com/microsoft/PowerToys/issues/8206#issuecomment-2209253752

JustGitn commented 3 months ago

Forgive me but I just wandered in and this seems very complicated and time consuming. What Is the quickest, easiest way to toggle modules between enabled & disabled?

ijgeoffrey commented 1 month ago

Forgive me but I just wandered in and this seems very complicated and time consuming. What Is the quickest, easiest way to toggle modules between enabled & disabled?

@JustGitn As far as I know, the current quick/easy way is to left-click once on the PowerToys tray icon, click "More..." in the upper-right of the popup, and then toggle the desired module. But frankly they still should add a shortcut to make it easier.

gn4881 commented 3 weeks ago

I support this feature to be implemented because we all need to toggle it easily