Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
oxitran opened this issue Jul 8, 2020 · 20 comments
Open

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

oxitran opened this issue Jul 8, 2020 · 20 comments
Labels
Help Wanted We encourage anyone to jump in on these and submit a PR. Idea-Enhancement New feature or request on an existing product Product-Keyboard Shortcut Manager Issues regarding Keyboard Shortcut Manager Product-Settings The standalone PowerToys Settings application

Comments

@oxitran
Copy link

oxitran commented Jul 8, 2020

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.

@ghost ghost added the Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams label Jul 8, 2020
@StuartKent17
Copy link

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.

@oxitran
Copy link
Author

oxitran commented Jul 13, 2020

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.

@saahmedm saahmedm added Idea-Enhancement New feature or request on an existing product Product-Keyboard Shortcut Manager Issues regarding Keyboard Shortcut Manager Product-Settings The standalone PowerToys Settings application labels Jul 24, 2020
@saahmedm saahmedm added this to the Suggested Enhancements milestone Jul 24, 2020
@saahmedm saahmedm removed the Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams label Jul 24, 2020
@arjunbalgovind
Copy link
Contributor

@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.

@enricogior enricogior changed the title Toggle key for Keyboard Manager [KBM] Add a toggle key to turn it on/off Feb 9, 2021
@enricogior enricogior changed the title [KBM] Add a toggle key to turn it on/off [KBM] Add a hotkey key to turn it on/off Feb 26, 2021
@crutkas crutkas added the Help Wanted We encourage anyone to jump in on these and submit a PR. label Dec 6, 2021
@Cheizr
Copy link

Cheizr commented Aug 20, 2023

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

@Meukbox
Copy link

Meukbox commented Dec 10, 2023

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
Copy link

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
Copy link

peyao commented Dec 15, 2023

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
Copy link

mattpang commented Jan 15, 2024

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
Copy link

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
Copy link

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
Copy link

I appreciate the guide! Thanks a lot

@mbybtjh
Copy link

mbybtjh commented Apr 8, 2024

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脚本了。

@crutkas crutkas mentioned this issue Apr 30, 2024
@DigitalHype
Copy link

@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
Copy link
Collaborator

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

#8206 (comment)

@JustGitn
Copy link

JustGitn commented Jul 7, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted We encourage anyone to jump in on these and submit a PR. Idea-Enhancement New feature or request on an existing product Product-Keyboard Shortcut Manager Issues regarding Keyboard Shortcut Manager Product-Settings The standalone PowerToys Settings application
Projects
Status: ⚠️Needs Walkthrough
Development

No branches or pull requests